CSS Classes

Estimated reading: 1 minute 58 views

CSS classes apply a specific style to multiple HTML elements by assigning the same class name.

				
					p { 
 font-size: small; 
 color: #333333
 }
				
			

Pretty simple, but lets say that I wanted to change the word "sentence"
to green bold text, while leaving the rest of the sentence untouched. I
would do the following to my (X)HTML file.

				
					<p>
 To put it more simply, this <span
 class="greenboldtext">sentence</span> you are reading is styled
 in my CSS file by the following.
 </p>
				
			

Then in my CSS file I would add this style selector:

				
					
 .greenboldtext{ 
font-size: small; 
color: #008080;
 font-weight: bold;
 }
				
			

To put it more simply, this sentence you are reading is styled in my CSS file by the following.

Share this Doc

CSS Classes

Or copy link