HTML Styles

HTML has a style attribute. Setting the style of an HTML element, can be done with the style attribute. For more information, you can look at the website under Styles. The HTML style attribute has the following syntax:

<tagname style="property:value;"> 

The property is a CSS property. The value is a CSS value.

  • Use background-color for background color
  • Use color for text colors
  • Use font-family for text fonts
  • Use font-size for text sizes
  • Use text-align for text alignment


Light Green Background Color

Light Green Background Color using hex #90EE90

Light Green Background Color using RGB 144, 238, 144

<h4 style="background-color:lightgreen;">Light Green Background Color</h4>
<h4 style="background-color:#90EE90;">Light Green Background Color using hex #90EE90</h4>
<h4 style="background-color:rgb(144,238,144);">Light Green Background Color using RGB 144, 238, 144</h4>

Light Blue Background Color with Red Text

<h4 style="color:red; background-color:lightblue">Light Blue Background Color with Red Text</h4>

My Header

<h4 style="color:white; background-color:blue; font-family:verdana; text-align:center">My Header</h4>

This is a paragraph in which we want to highlight some text within the paragraph. We can use the span tag around the text we wish to format. In this case we use style and set it equal to background-color:pink. has a really good tutorial section on color.

There is another post: HTML Inline Styles with more information like this.

Leave a comment

Your email address will not be published. Required fields are marked *