CSS – Buttons

With CSS, we can easily style buttons as well. The styling includes changing the button color, font size, and width, enabling hover, creating rounded buttons, etc. Let us see the examples one by one:

  • Change the Button Color
  • Change the Button Font Size
  • Set Button Border
  • Change the Button Width
  • Create Rounded Buttons
  • Set Disabled Button
  • Set Shadows to a Button

Change the Button Color

The background-color property is used to change the color of a button in CSS. Let us see an example:

Output

CSS Buttons Change the Color

Change the Button Font Size

To change the font size of a button, use the font-size property in CSS. Let us see an example:

Output

CSS Buttons Change the Font Size

Set Button Border

The border property is used in CSS to set the border of a button. Let us see an example:

Output

CSS Buttons Set the Border

For more examples of borders in CSS, refer to Style Borders in CSS.

Change the Button Width

To change the width of a button in CSS, use the width property. Let us see an example:

Output

CSS Buttons Change the Width

Create Rounded Buttons

The border-radius property is used to create rounded buttons in CSS. Let us see an example:

Output

CSS Buttons Rounded

Set Disabled Button

Set a button to be disabled in CSS using the opacity property. Also, use the cursor property and set it to not-allowed i.e. the requested action will not be executed. Let us see an example:

Output

CSS Buttons Disabled

Set Shadows to a Button

The box-shadow property is used in CSS to set the shadows to a button. Let us see an example:

Output

CSS Buttons shadow

If you liked the tutorial, spread the word and share the link and our website Studyopedia with others.


Read More:

CSS - Position
CSS - Animations
Studyopedia Editorial Staff
contact@studyopedia.com

We work to create programming tutorials for all.

No Comments

Post A Comment

Discover more from Studyopedia

Subscribe now to keep reading and get access to the full archive.

Continue reading