Selectors - Notes Lyst5656
Selectors - Notes Lyst5656
CSS - Day 3
Agenda
▪ CSS Selectors
CSS SELECTORS:
CSS selectors are used to select the content you want to style. CSS
Selectors are used to select HTML elements based on their element
name, id, attributes, etc. It can select one or more elements
simultaneously. There are many different types of CSS selector they
are listed below.
CSS SELECTORS
OUTPUT:
index.css
As we can see in the output element selector selects all the elements
that matches the selector in this program it is h1 and applies the styling.
If you mention the selector as p tag it will select all the element that
matches p tag and applies styling. If we select boby element as a
selector then styling is applied to body of the html page, if we change
the css file of the above example.
Output:
As we can see in the output using body element, we can style the body
of the elements, if you recollect output is similar to that of universal
selector but there is a difference between universal selector and element
selector. Now let’s understand the difference between universal
selector and element selector with an example.
index.css
Output:
index.css
Output:
Output:
As we can see from the above example using class selector we can
group different elements into a certain class and apply styling.