You can define your own selectors in the form of Class & ID selectors. Benefit of the Class & ID Selectors are allows to present same HTML element with different styles.
- CSS - Class
Class selector uses the HTML Class attribute and preceded by ".". The class selector is used to specify styles for group of elements. Class selector can be used for several elements.
Ex:
CSS part :
.color{
color : red;
}
HTML Part:
<p class = "color">This is a styled paragraph</p> - CSS - ID
The ID selector is used to specify a style for single, unique element. ID selector uses the HTML ID attribute and preceded by "#".
Ex:
#top{
background-color: yellow;
color : red;
}
HTML part:
<div id = "top">
<h2> ----- </h2>
<p>----</p>
</div>
No comments:
Post a Comment