It is time consuming and not very practical to style HTML elements using the style attribute.
The preferred way to add CSS to HTML, is to put CSS syntax in separate CSS files.
However, in this HTML tutorial we will introduce you to CSS using the style attribute. This is done to simplify the examples. It also makes it easier for you to edit the code and try it yourself.
HTML Style Example - Background Color
The background-color property defines the background color for an element:
Example
|
The background-color property makes the "old" bgcolor attribute obsolete.
HTML Style Example - Font, Color and Size
The font-family, color, and font-size properties defines the font, color, and size of the text in an element:
Example
|
The font-family, color, and font-size properties make the old <font> tag obsolete.
HTML Style Example - Text Alignment
The text-align property specifies the horizontal alignment of text in an element:
Example
|