i just started programming and I wanted to try css with html. However, I keep running into errors like these where I want a button, however when displayed on browser the said button becomes a link. can someone explain?
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Linking External Style Sheets</title>
<style>
h1 {
color: blue;
}
a {
color: blue;
text-decoration: none;
}
a:hover {
background-color: yellow;
}
</style>
</head>
<body>
<div><p><em>Click here:</em>
<a class="w3-btn" href="http://www.w3schools.com">Link Button</a>
</div>
</body>
</html>
I wanted to give it a border, background and text color also, and make it change when theres a mouse over it with the code...
If you want a button then simply use <button> instead of <a>:
<button class="w3-btn" href="http://www.w3schools.com">Link Button</button>
However, you can't use href with a button since buttons are suited for forms. In this case you can either style the link to look like a button (@RahulB answer) or wrap the (real) button in a form which submits to http://www.w3schools.com.
<form action="http://www.w3schools.com" method="POST">
<button class="w3-btn" type="submit>Link Button</button>
</form>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With