CSS Class Selectors

Similar to an ID selector, a class selector is used as an attribute of an HTML tag via the class attribute. Classes, like all css, can be defined in the head of an html document. When defined, a class name must start with a period. See the code for this page to see the two class rules that are already defined and what their properties are. You can use almost any word you want to name the class but it should be alpha-numeric with no spaces.

A class can be applied to any tag where its specifications are relevant. For example, specifying a font in a class rule and then applying that class to an image tag will have no effect.

In the examples below, the classes are applied to font formatting tags, which is appropriate because the classes in this case assign text formatting values such as text color, italics, and point size. In the examples below, the class attribute is being used with the <big> and the <b> tags, however in each example a different class is being applied. Check out the code:

This is really, really, really important.

This is even more important

Your assignment:

  1. Create a new class giving it a new name of your choice (but it needs to be alpha-numeric and without spaces).
  2. See the document head for examples.
  3. Use the values of:
  4. Refer to the code in the head of this document for the syntax needed. Also, find the way that those two classes are applied using the class attribute in the code and mimic that as well.
  5. Apply your new class to this word using the italics tag already there to contain your class attribute.
  6. Save the file as
    CSS_Class_yourlastname.html
  7. Send it to me by email.

© 2008 Dan Hitchcock Vaughan and its licensors. All rights reserved.