Anotomy of HTML Elements and CSS Rules
A set of HTML tags or a 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 elememt's anatony...
Below is an image of a CSS rule's anaomy...
Types of CSS selectors
There are three main types of CSS selectors...
- Element Selectors: are use to select HTML elements (ex. div, ul, img, h2,...)
- Class Selectors: are used to select HTML elememts with class attributes. Class selectors use the . in front of the class name in CSS
- ID Selectors: are used to select HTML elements with id attributes. These use # im from of the id name in CSS.
Note: When you are styling a website using CSS. It is best to use only class selectors and element selectors when necassay.Use a selector in CSS to change this HTML element
Use a class selector to change this.
Use an id slector to change this.
It is possible to delcare more than one class on an HTML element. This allows yhou to save time by only having to write a CSS rule once and then reuse it.
This paragraph has a color.
This paragraph is bold.
This paragraph has combined classes form the two above it.