Hello again.
We already saw the HTML selectors that are used to represent texts like paragraphs,
and everything's like you saw previously.
But you can also define your own selectors using classes and I d selectors.
The benefits of using classes and I DS is that you can have the same HTML element but
present it differently depending on his class or I D.
So I can have more than one paragraph in a page that can have different styles because they
use different classes or ID's in the CSS.
A class selector is the name preceded by a dot and an I.
D selector is a name preceded by a Nash character,
now more in detail and starting with glasses like I said can be used when you want
different styles of a particular element.
For this example,
I have two paragraphs and then adding,
and I want to style two paragraphs using different text,
color and font sizes.
First paragraph with front size 20 pixels and color blue and second pair riff farting
pixels and color brown.
Within our HTML cold.
We assign a particular class by using the class attributes within our tech for the
situation.
I need to different classes because I want different styles.
Defining first paragraph with name first and second with name.
Second when I defined these two classes in CSS,
always starting with that followed bike Last name I use for class first,
front size with value 20 pixels and color blue and for my class seconds the same properties
front size,
but now with value 14 pixels and color with value brown,
you can distinguish now these different styles in the browser.
As you can see.
Other thing I can make that is a little bit different is affect all elements that I want
with the same style.
For this example,
I just want to have the same style used for first paragraph in my having element,
joining the adding with class first using coma to separate the two texts.
And now the style is similar to both elements.
So the great advantage of using classes is that I can reuse the same styles in multiple
elements.
Next step is I D selectors Debt in CSS allow you to target elements by their I D values.
The big difference when compared with classes,
is that I the selectors,
are unique.
So you can apply on Lee to the content off one element.
If you remember in HTML,
I d can be used to create an anchor tooling to a specific part off the page.
And if you include Martin when I d.
The browser will not know where to go when you make reference to the i D.
Because that I d is used in different parts off the HTML document.
That's what you see in the file own dot html that I create previously,
where I have an anchor defined that makes that stoppage link jumped to the element that as
the i d back top that is my adding one element.
If you have more than one element with these I d.
Name the browser,
don't know where to go.
This is a simple example to understand why I d is only used one time we'd same value.
So using the previous example used in glasses,
I change now class to I D.
And where I defined the styles instead of use a point before die.
The name I used the hash tech for this first situation.
I don't change the style for my adding element.
As expected,
the final.
I'll put a similar like when I used glasses applying different styles to the paragraphs.
If now I want to change the style for the ending to be similar with first paragraph,
you cannot use I d selector because,
like I said,
you cannot use a mighty in different elements in your documents.
So the better way is to use a class to effect paragraph and adding,
We'd same style like ideas before thanks.