Web Design/CSS Classes

What are Classes in CSS?
 * Let's say you want to give an HTML element multiple looks with CSS.
 * Say for example, sometimes you want the font to be small and white with a black background, while other times you would prefer the font to be big and blue with a light blue background. CSS allows you to do this with the use of classes.
 * The name of the actual class can be called whatever you wish!

To make a class, in between & type the name of the class following the tag name. p.first { color: blue; } Then in the HTML tag add the class This is some text

The last code will set the text color to blue for all of the 'p' elements with a class value of 'first'. It's also possible to apply the desired style to all of the elements with an specific class value no matter which element the class attribute is at. To do that, the '*' character is used.
 * .first { color: blue; }

Example 1

The code below should make the:
 * Paragraph with the first class, appear as blue color.
 * Paragraph with the Second class, appear as red color.
 * Paragraph with the no class, appear as normal.

Type the code below into your code editor and save the file as cssclass.html

 p.first{ color: blue; } p.second{ color: red; }

This is a normal paragraph.

This is a paragraph that uses the p.first CSS code!

This is a paragraph that uses the p.second CSS code!

Example 2

The code below should make the:
 * Heading2 appear red with font size of 20px.
 * Paragraph with the firstpara class, appear as gray color.
 * Paragraph with the Secondpara class, appear as red color.
 * Paragraph with the Thirdpara class, appear as white text with purple background.
 * Paragraph with the no class, appear as normal.

Type the code below into your code editor and save the file as cssclass2.html

h2 { color: red; font-size: 20px; } p.firstpara { background-color: gray; } p.secondpara { background-color: red; } p.thirdpara { background: purple; color: white; }

CSS Classes This is the p.firstpara paragraph

This is the p.secondpara paragraph

This is the p.thirdpara paragraph

This has no CSS formatting

References

http://www.tizag.com/cssT/class.php