I’m not getting to call class in css in the conventional way

Asked

Viewed 80 times

-3

I’m starting to use vs code now, but when I try to reference a class created in html code, by css, I need to do without a point, I can’t understand what kind of error this might be. follows the 3 codes(index.html, footer.css and index.css).

<!DOCTYPE html>
<html>
<head>
    <meta charset='utf-8'>
    <meta http-equiv='X-UA-Compatible' content='IE=edge'>
    <title>MInha Pagina</title>

    <meta name="viewport" content="width=device-width, initial-scale=1">

    <link rel="stylesheet" type="text/css" media="screen" href="./Assets/css/index.css" />
    <script src='main.js'></script>
</head>
<body>
    <header></header>
    <section>
        <article>
        </article>
    </section>
    **<footer>
        <h1 class="text">
           green
        </h1>
    </footer>**

</body>
</html>
@import url('./footer.css');
@import url('./header.css');
@import url('./reset.css');
@import url('./section.css');

Code that should work:

.footer {
   color:green;
 }

Code that is working (without the point):

footer {
  color:green;
}

1 answer

4

That is correct.

It will not work with the dot in front as your html has no element with class="footer", only the element <footer>

.footer { color: red } /* classe */
footer { color: blue } /* elemento */
<footer class='footer'>Footer I</footer> <!-- classe -->
<footer>Footer II</footer> <!-- elemento -->

Browser other questions tagged

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