4
I did an example of CSS code to learn a little bit more about the use of classes. However, I realized a mistake and I can’t quite understand why.
1° example
.fonte-style-h1 {
vertical-align: middle;
font-size: 30%;
color: yellow;
text-shadow: -1px 0 black, 0 1px black, 1px 0 black, 0 -1px black;
}
<!DOCTYPE html>
<html>
<head>
<title>CSS</title>
</head>
<body>
<h1 class=".fonte-style-h1">Oie CSS!</h1>
</body>
</html>
Note in this example I created the class .fonte-style-h1
to define a style for tag content h1
and see that there was no effect.
2° example
h1 {
vertical-align: middle;
font-size: 250%;
color: seagreen;
text-shadow: -1px 0 black, 0 1px black, 1px 0 black, 0 -1px black;
}
<!DOCTYPE html>
<html>
<head>
<title>CSS</title>
</head>
<body>
<h1>Oie CSS!</h1>
</body>
</html>
In this second example see that I applied style to the tag h1
in a general way and it worked. It is at this point that my doubt arises.
Question
Why class .fonte-style-h1
does not apply style to tag h1
and when I use h1
instead of the class it works?
A hint is that the same one applies to the ID, where in the . CSS would be
#nome-do-id {estilos}
and in HTML you would have<elemento id="nome-do-id">
thenid="#nome-do-id"
would also be wrong.– hugocsl