top of page

How to create a simple button

Writer: Web Coding
Web Coding
Sep 6, 2020
1 min read

Learn how to create a simple button using only HTML and CSS

HTML

<!DOCTYPE html>
<html lang="en">
<head>
 <meta charset="UTF-8">
 <meta name="viewport" content="width=device-width, initial-scale=1.0">
 <title>Document</title>
 <link rel="stylesheet" href="style.css">
</head>
<body>
 <button type="button">Subscribe!</button>
</body>
</html>

CSS

*{
 padding: 0;
 margin: 0;
}

body{
 min-height: 100vh;
 display: flex;
 align-items: center;
 justify-content: center;
 background-color: #333;
}

button{
 position: relative;
 cursor: pointer;
 background-color: red;
 color: white;
 height: 40px;
 width: 120px;
 border-radius: 4px;
 border: none;
 outline: none;
 box-shadow: 0px 5px 0px maroon;
}

button:hover{
 opacity: 0.9;
}

button:active{
 opacity: 0.9;
 box-shadow: none;
 top: 5px;
}

If you found this blog post helpful don’t forget to check out my other projects and if you want more content follow me on


YouTube: https://www.youtube.com/channel/UC2nxqB2usQIS2c8zwVZKWEQ

Instagram: https://www.instagram.com/coding_for_the_web/

Twitter: https://twitter.com/LearnWebCoding

Comments


  • YouTube
  • Instagram

©2020 by Web Coding. Proudly created with Wix.com

bottom of page