Lesson 8: A Bit About Styles

Styles are a way to control the appearance of HTML elements. HTML elements can be given styles with the style attribute, or styles can be defined in Cascading Style Sheets (known as CSS) that apply to specific tags. In this example, all paragraphs use the font family Times New Roman and a size of 20 pixels, unless the style attribute overrides this setting.

In this brief introduction to HTML, we must skip discussing CSS. This is just a taste of it, with some examples that use the style attribute below.

This text is in Verdana and red.

The above text is created with the tag
<p style="font-family:verdana;color:red">

This text is in Times New Roman and navy blue.

The above text is created with the tag
<p style="font-family:times new roman;color:navy">

This text is 24 pixels high

This web page is a list of the names of colors that you can use in a web page, with the hexadecimal values for them.

Some methods of controlling style are deprecated. This means that they should not be used because browsers will eventually stop recognizing them. Do not use <font>, <center>, <align>, <color>, or <bgcolor>. Use styles instead.