Southend Linux User Group

Using CSS

Cascading Style Sheets (CSS)

HTML was not designed for formatting. The formatting was left to the particular browser. As the Internet grew this limitation was overcome by the introduction of Cascading Style Sheets (CSS). These notes delve into some of the basic and more complex examples involving style sheets but it is by no means complete.

Advantages of CSS

  • Control layout of many documents from one single style sheet
  • More precise control of layout
  • apply different layout to different media-types, screen or print for example.
  • Style rules are accessible to scripting and so can be changed dynamically

Using CSS

Most HTML tags support the style property that can be used to give much greater flexibility over the format of a page. It makes the style of the document accessible to script languages, so that document styles can be changed dynamically. Common styles can be applied across many pages, to give them a similar look and feel.

Document styles can be applied in 3 different ways.

The order the tags are listed below is important.

  • A local, or in line tag will override all others.
  • Using a tags (unique) identifier will overide class and general tag styles.
  • finally a class specifier will override the general formatting applied to a tag name

local (or inline style)

By specifying the style to be used for a particular tag
E.g. make this italic

tag

Relating a style to a particular tag name so that all tags with that name have the same style applied. E.g.

   
tag id Attach a style to a unique id, e.g. #logo. Notice the use of the hash (#) symbol to denote an ID.

   

Author: Alan Campion - Page reference: 3014
Last modified: Alan Campion - 2015-08-31