Anatomy of html Elements and Css Rules
A set of html tags or a singular /self-closing Html tags is called and html element
A set of Css code is called Css rule.
Below is an image of an html element's anatomy...
Types of Css Selectors
- Element Selectors: are used to select Html elements (ex. ,div,ul,img,h2...)
- Class Selectors: are used to select Html elements with class attribute Class. Class selectors use the. in front of the id name css.
- ID Selectors: are used to select html elements with id attributes. These use # in front of the id name in Css.
Note:When you are styling a website using Css, it is best to use only class selectors and elements selectors when necessary.Use a selector in Css to change this html element.
Use a class selector to change this.
Use a id selector to change this.
It is possible to declare more than one class on an html element. This allows you to save time by only having to write css rule once and then reuse it.
This Paragraph has a color
This paragraph is bold.
This paragraph has combine classes from the two about it.