In the example given in this exercise, why would we want to use the `.brand` selector rather than the `p` selector to target our paragraph?


#1

Question

In the example given in this exercise, why would we want to use the .brand selector rather than the p selector to target our paragraph?

Answer

The code snippet used in this exercise is purely for demonstrative purpose. However, you can imagine a project where we had multiple <p> elements. Say we only wanted to target a fraction of those elements for styling. We could apply a class attribute specifically to the <p> tags containing the text we wanted to style. In this case, we target the <p> elements we want to style while ignoring those <p> elements we do not want to style.

More generally, this example illustrates how we can use classes to more narrowly target groups of elements.


FAQ: Learn CSS Selectors Visual Rules - CSS Setup Selectors - Class Name
#2

Do variables on computers work like this?, we could have a class and appy changes not only to the class but also to other elements that are out of that class, such as parts and sections of a program or an app?
I’m sorry if this is a too confused question


#5

What do you mean by computer variables?


#6

Thanks for the insight!


#7

Someone please explain to me why this style for

not active when I add a CSS selector:
In HTML file

Top Vacation Spots

In file style.CSS, I code that: h1 { color: maroon; } .title { color: teal; font-size: 40 px; } why the text "Top Vacation Spots" isn't maroon in colour and it changes to color teal ??? Maybe there is an order between tag

and class attribute when we style it in CSS?


#8

the use of the “.title” selector overwrites the “h1” selector.