top of page
Writer's pictureWeb Coding

How to create a simple button

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

*{
 padding0;
 margin0;
}

body{
 min-height100vh;
 displayflex;
 align-itemscenter;
 justify-contentcenter;
 background-color#333;
}

button{
 positionrelative;
 cursorpointer;
 background-colorred;
 colorwhite;
 height40px;
 width120px;
 border-radius4px;
 bordernone;
 outlinenone;
 box-shadow0px 5px 0px maroon;
}

button:hover{
 opacity0.9;
}

button:active{
 opacity0.9;
 box-shadownone;
 top5px;
}

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

3 views

Comments


bottom of page