Anatomy of HTML Elements and CSS Rules
A set of HTML tags or singular/self-closing HTML tag is called an HTML element.
A set of CSS code is called a CSS Rule.
Below is an image of an HTML element's anatomy.....
Below is an image of a CSS rule's anatomy....
Types of CSS Selectors
There are three main types of selectors...
- Element Selectors: are used to select HTML elements (eex. div, ul, img, h2,....
- Class Selectors: are used to select HTML elements with class attributes. Class selectors use the . in front of the class name in CSS.
- ID slectors: are used to select the html elements with id attributes. These use the # in front of the ID name in CSS
NOTE:When you are styling a website using CSS, it is best to use class selectors and element selectors when necessary.Use a selector in CSS to change this HTML element
Use a class selector to change this.
Use 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 a CSS rule once and then reuse it
This paragrapgh has a color
This paragraph is bold
This paragraph has combined classes from the two above it.