CSS Id and Class
I addition to setting a style for HTML elements CSS allows you to specify your own selectors called "id" and "class"
- It's used to specify a style for single and unique HTML elements
- It's using the id attribute of the HTML elements and is defined with a hashtag "#"
- Do not start an Id name with a number it will not work in the browser.
<p id ="paragraph"> How are you?</p>
The class selector is used to specify a style for a group of elements. Unlike the id sector, the class selector is most often used for several elements.
- It's allowing you to set a particular style for many HTML elements with the same class.
- The class selector uses the HTML class attribute and is defined with a preceded by a period ("."). Like. paragraph
- Do NOT start a Class name with a number because some browser does not support it.
<p class ="paragraph"> How are you?</p>
Leave a comment
No Cmomments yet