Applying Styles to Elements ("Tags")

To assign a style to all instances of a given element, just write the name of the tag, then type the style attributes inside of the curly brackets. Remember to put semi-colons at the end of each style declaration.

Oftentimes it is helpful to assign styles to the <body> element. These styles will apply to all of the content in the document.

body {
  font-family:Verdana, Arial, Helvetica, sans-serif;
  }  

It is possible to override the <body> styles by assigning styles to other elements that appear within the <body> of the document. Here is an example of a style that will apply to all links (e.g. all instances of the <a> tag):

a {
  background-color: blue;
  color: white;
  }  

Below are examples of styles applied to headings:

h1 {
  color:#990000;
  font-size:1.7em;
  }  
h2 {
  color:#990000;
  font-size:1.4em;
  border-top:#990000 solid 1px;
  }  

A simple document with these styles would look something like this:

This is a heading level 1

This is a paragraph. Here is a link to George Mason University.

This is a heading level 2

This is another paragraph.

Creative Commons License
This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 2.5 License.