HTML – Style

  • HTML Style is used to add style to the element like, font-size, color, background-color, margin, padding, text-decoration, etc.

Here are some commonly used properties:

Syntax:

background-color code snippet

a) background-color:

  • Background color is used to set the background color of any element.

Example:

HTML Style - syntax

🚀 Try it yourself! Click the button below to run the code and see the output in action.

HTML Code

Output

b) Font Size:

  • font-size is used to increase or decrease the size of the font.

Example:

font syntax

🚀 Try it yourself! Click the button below to run the code and see the output in action.

HTML Code

Output

c) Margin:

  • It controls the space outside the element, creating distance between the element and its neighbors. It affects the spacing around the element.

Example:

margin syntax

🚀 Try it yourself! Click the button below to run the code and see the output in action.

HTML Code

Output

d) Padding:

  • It controls the space inside the element, creating distance between the element’s content and its border.

Example:

HTML Style - padding syntax

🚀 Try it yourself! Click the button below to run the code and see the output in action.

HTML Code

Output

Above are some examples

Important Note: Want to download the full HTML course as a PDF? Click here to save it locally!

Leave a Comment