Wednesday, June 14, 2017

How to create buttons with background color using HTML and CSS

How to create buttons with background color using HTML and CSS

Button Colors

Change the background color of a button using the background-color property




Sample code: To Create Buttons


<!DOCTYPE html>
<html>
<head>
<style>
    .button
    {
        background-color: gray;
        border: none;
        color: white;
        padding: 14px 28px;
        text-align: center;
        text-decoration: none;
        display: inline-block;
        font-size: 14px;
        margin: 4px 2px;
        cursor: pointer;
    }

    .button1 {background-color: red;}
    .button2 {background-color: green;}
    .button3 {background-color: blue;}
</style>
</head>
<body>
    <h2>Button Colors</h2>
    <p>Change the background color of a button using the background-color property</p>
    <button class="button button1">Red</button>
    <button class="button button2">Green</button>
    <button class="button button3">Blue</button>
</body>
</html>

No comments:

Post a Comment