Posted on Jan. 26, 2021, 8 p.m. by Bishal ( 7179)
<button>
is an element used to create a clickable button. The button created in this tutorial gives visitors an attractive simple button made with HTML and CSS.
<input type="button">
?
<button> </button>
element We can Put texts, embed elements like the <p> </p>
tags,<b> </b>
tags, <strong> </strong>
tags, <br>
and <img src="">
tags. We can't embed these tags inside <input type="button">
<button> </button>
has a type=""
attribute which is submit
by default i.e. <button type="submit"> Submit </button>
. So it is always a good practice to define the type of the button. Here are some examples:
<button type="submit"> Submit Button </button>
<button type="button"> Button </button>
<button type="reset"> Button </button>
Browser Support | Chrome | Internet Explorer | Opera Mini | Firefox | Safari |
<button>
| Yes | Yes | Yes | Yes | Yes |
---|
Attribute |
autofocus
|
Usage |
<button autofocus> Autofocus </button>
|
Demo |
|
index.html
index.html
<!DOCTYPE html>
<html>
<head>
<title>Simple Button - Code With Bishal</title>
</head>
<!-- created by Code With Bishal - www.codewithbishal.com
-->
<body>
</body>
</html>
style.css
<head> </head>
of your HTML document:<link rel="stylesheet" href="style.css">
style.css
file.button {
border-radius: 4px;
background-color: #00FFFF; /* change this to change the colour of button */
border: none;
color: #3333ff; /* change this to change text colour */
text-align: center;
font-size: 38px; /* change this to change the font size */
padding: 20px;
width: 600px; /* change this to change the width of the button */
transition: all 0.5s;
cursor: pointer;
margin: 5px;
}
<!DOCTYPE html>
<html>
<head>
<title>Simple Button - Code With Bishal</title>
</head>
<!-- created by Code With Bishal - www.codewithbishal.com
-->
<body>
<button type="button" class="button">Change this to change text</button>
</body>
</html>
.button {
border-radius: 4px;
background-color: #00FFFF; /* change this to change the colour of button */
border: none;
color: #3333ff; /* change this to change text colour */
text-align: center;
font-size: 38px; /* change this to change the font size */
padding: 20px;
width: 600px; /* change this to change the width of the button */
transition: all 0.5s;
cursor: pointer;
margin: 5px;
}