Course Content
CSS Basic
0/1
CSS Selectors
0/1
CSS Comments
0/1
CSS Backgrounds
0/1
CSS Borders
0/1
CSS Outline
0/1
CSS Fonts
0/1
CSS Height and Width
0/1
CSS Margins and Paddings
0/2
CSS Icons
0/1
CSS Links
0/1
CSS Lists
0/1
CSS Tables
0/1
CSS Display Properties
0/1
CSS Max-Width Property
0/1
CSS Positioning Elements
0/1
CSS Z-Index Property
0/1
CSS Overflow
0/1
CSS Float
0/1
CSS Opacity
0/1
CSS Forms
0/1
CSS Dropdowns
0/1
CSS Buttons
0/1
CSS Media Queries
0/1
About Lesson

CSS provides various properties that you can use to style buttons and create different visual effects.

1. Background-color:

Syntax:

button {
background-color: #4CAF50; /* Hex color code or color name */
}

Example:

Html code:

    <button class=”green-button”>Click me</button>
    <button class=”blue-button”>Click me</button>
    <button class=”grey-button”>Click me</button>

CSS code:

    <style>
        .green-button {
            background-color: #4CAF50;
        }
        .blue-button {
            background-color: blue;
        }
        .grey-button {
            background-color: grey;
        }

    </style>
 

Output:


2. color:

Syntax:

button {
color: white; /* Hex color code or color name */
}

Example:

Html code:

    <button class=”green-button”>Click me</button>
    <button class=”blue-button”>Click me</button>
    <button class=”grey-button”>Click me</button>

CSS code:

    <style>
        .green-button {
            background-color: #4CAF50;
            color:black
        }
        .blue-button {
            background-color: blue;
            color: white;
        }
        .grey-button {
            background-color: grey;
            color: rgb(74, 8, 136);
        }
    </style>
 

Output:


3. Padding:

Syntax:

button {
padding: 5px; 
}

Example:

Html code:

    <button class=”green-button”>Click me</button>
    <button class=”blue-button”>Click me</button>
    <button class=”grey-button”>Click me</button>

CSS code:

    <style>

        .green-button {
            background-color: #4CAF50;
            color:black;
            padding:5px;
        }
        .blue-button {
            background-color: blue;
            color: white;
            padding: 2px;
        }
        .grey-button {
            background-color: grey;
            color: rgb(74, 8, 136);
            padding: 10px;
        }

    </style>
 

Output:


4. Border:

Syntax:

button {
border: 2px solid black;
}

Example:

Html code:

    <button class=”green-button”>Click me</button>
    <button class=”blue-button”>Click me</button>
    <button class=”grey-button”>Click me</button>

CSS code:

 

    <style>
        .green-button {
            background-color: #4CAF50;
            color:black;
            padding:5px;
            border: 2px solid black;
        }
        .blue-button {
            background-color: blue;
            color: white;
            padding: 2px;
            border: 5px solid white;

        }
        .grey-button {
            background-color: grey;
            color: rgb(74, 8, 136);
            padding: 10px;
            border: 10px solid  rgb(74, 8, 136);

        }

    </style>
 

 

Output:


5. Border-radius:

Syntax:

button {
border-radius: 4px; 
}

Example:

Html code:

    <button class=”green-button”>Click me</button>
    <button class=”blue-button”>Click me</button>
    <button class=”grey-button”>Click me</button>

CSS code:

    <style>
        .green-button {
            background-color: #4CAF50;
        }
        .blue-button {
            background-color: blue;
        }
        .grey-button {
            background-color: grey;
        }

    </style>
 

Output:


6. Hover effects (using :hover):

Syntax:

button:hover {
background-color: #4CAF50; /* Hex color code or color name */
}

Example:

Html code:

    <button class=”green-button”>Click me</button>
    <button class=”blue-button”>Click me</button>
    <button class=”grey-button”>Click me</button>

CSS code:

    <style>
        .green-button {
            background-color: #4CAF50;
        }
        .green-button:hover {
            background-color: #e0f5e1;
        }
 
        .blue-button {
            background-color: blue;
        }
        .blue-button:hover {
             background-color: rgb(108, 108, 211);
        }
 
        .grey-button {
            background-color: grey;
        }
        .grey-button:hover {
            background-color: #e0f5e1;
        }
 

    </style>
 

Output: