Cascading Style Sheets

From Higher Computing Science
Jump to: navigation, search

Key Points

  • Cascading Style Sheets are used to store style and layout information for a web page.
  • A CSS file by itself does not have any web content. A CSS file is used in conjunction with a web page to determine the style of HTML elements, such as font, style or colours.
  • A CSS selector is a tag name (like p, h1, a), identifier (given to one element of HTML using the id attribute) or class (given to one or more elements of HTML using the class attribute)
  • Each individual element can be given a style using CSS by adding a style attribute to the code. This allows a web developer to control every tag on screen and how it looks, but is time consuming if the user wants to apply styles to many elements.
  • CSS code can be added directly to HTML within a style tag, which sits within the head area of an HTML document. This allows the web developer to write styles into the HTML file itself, in CSS code.
  • CSS code can be stored in an external file. This can be linked to the HTML file through a link tag containing the address of the file.
  • CSS uses cascading to decide which code to use. It will set all styles according to an external CSS file, then update or add styles mentioned in the head area of the HTML document, then apply individual styles used as an attribute in a tag.
  • CSS can specify groups of code for different devices/uses such as print, screen and media

Information

Examples

Videos

 

Further information

Test yourself

Teaching resources

PI questions on CSS CSS/HTML introduction worksheet Online quiz on CSS Exam style questions