HTML CSS Lesson 2 Classes

➧ HOME

CSS Lesson 2 Classes

The Class selector in CSS allows you to create different styles for different elements within the same CSS document. For example, I have been using a bold font to display program code within my documents. If I wanted to make the code stand out even more, I could make it bold as well as change the color to red. I would do this by creating a new class for my code examples. The new class "code" would be inserted either in the head of my document or in the style sheet. The class name begins with a period "."


For example:


	<style>
	 
		.code{ 
			 color: red;
 			 font-weight: bold;
			 font-size: large; 
		}
		 
	</style>
 
	


So when I am showing a piece of code, I could make it stand out in bold text with a red color by inserting this tag

		<span class=”code”>Code Example</span>
	

<span class=”code”>Code Example</span>


I hope you'll join me for the next lesson Lesson 3) CSS ID

Additional Resources