Difference between selector.class and . selector class

Asked

Viewed 35 times

1

Hello, everyone. I’m a beginner in programming and I have a question in CSS. In a code where I want all H5 who have the class . special be red, there is some difference between H5.special and . special H5? Using H5.special, I got what I wanted, but using . special H5, I did not get the same result. Why? When should I use the selector after the class and the reverse?

HTML:

 <html>
    <head>
        <link rel="stylesheet" type ="text/css"  href="style.css"/>
    </head>
 <body>
        <h5 class="special"> Destino </h5>
        <br> texto texto texto texto texto texto <br>
        <br> texto texto texto texto texto texto <br>

        <h5>Destino </h5>
        <br> texto texto texto texto texto texto <br>
        <br> texto texto texto texto texto texto <br>

        <h5 class="special"> Destino</h5>
        <br> texto texto texto texto texto texto <br>
        <br> texto texto texto texto texto texto <br>
</body>
</html>

CSS:

h5.special {
color: red;
}

Thank you in advance.

1 answer

0

.special H5 means: in H5 that are within . special should be red

<h5>Cor padrão</h5>
<div class="special">
<h5>Aqui deve aparecer vermelho</h5>
</div>

Browser other questions tagged

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