html button | button in html #html #htmlcss
HTML BUTTON
To create a button in HTML, you can use the <button> element. Here's an example of how you can create a button:
<!DOCTYPE html>
<html>
<head>
<title>Button Example</title>
</head>
<body>
<button type="button">Click Me!</button>
</body>
</html>
In this example, the <button> element is used to create a button. The type attribute is set to "button" to specify that it is a button element. Inside the button element, you can add the text or any other content you want to display on the button.
You can customize the button further by adding CSS styles or additional attributes to the <button> element. For example, you can add a class or an ID to the button and style it using CSS rules.
Here's an example with some additional customization:
<!DOCTYPE html>
<html>
<head>
<title>Button Example</title>
<style>
.custom-button {
background-color: #4CAF50;
border: none;
color: white;
padding: 10px 20px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
margin: 4px 2px;
cursor: pointer;
}
</style>
</head>
<body>
<button type="button" class="custom-button">Click Me!</button>
</body>
</html>
In this example, a CSS class called "custom-button" is defined and applied to the button. The class adds custom styles to the button, such as a green background color, white text, padding, and more. Feel free to modify the styles to fit your requirements.
save the HTML code in a file with a .html extension and open it in a web browser to see the button in action.
Comments
Post a Comment