What’s the difference between these two selectors?

Asked

Viewed 39 times

0

I wanted to know the difference between those two ways:

primeiro {
width: 50px;
float: left;
background-color: blue;
height: 50px;
padding: 7px;
}

.primeiro {
width: 50px;
float: left;
background-color: red;
height: 50px;
padding: 7px;
}
<primeiro> </primeiro>
<div class="primeiro"></div>

  • 1

    The first is a tag and the second a class.

  • The difference is just how you selected the element.

  • I can make a whole site tag then?

  • 1

    "Can", doesn’t mean you should...

  • Yes, but you must be careful with semantics

  • Got it, guys. I’m going to do a little research and a little digging into this. Thank you all very much.

  • You also have to see what the context of this tag is <first></first>. If you are using a framework JS like Angular or Vue, for example, this tag indicates a component.

  • 1

    What if you have two tags with the same name, but want a left and a right Coo will do? The first option you put in is like a global selector for all elements of the same name, it can be good or bad...

Show 3 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.