-2

enter image description hereI have learned HTML and CSS a year ago and this year i wanted to learn JS. I am revisiting my old HTML projects and i am trying to refresh my HTML and CSS by making a new one. I tried to start simple and write some text in HTML and than make it look better with CSS. So i typed my text in HTML and tried changing it with CSS. But no matter what i do, if it is in an external .css file or in a <style> attribute, the HTML doesn't change.

This is my HTML code:

<body>

<div class="higher-or-lower">
 <h1 class="first-title">Higher or lower?</h1>
 <h2>Choose between higher and lower</h2>
 <p>Is the number higher or lower then the previous</p>
</div>

<style>
    higher-or-lower {
        margin-left: 200px;
    }

    first-title {
        color: #ff00ff;
    }

</style>


</body>
</html>
2
  • classes need a "." before them in the CSS
    – gman
    Commented May 16, 2020 at 15:37
  • higher-or-lower {.. and first-title {.. should start with dot . .higher-or-lower because is a class Commented May 16, 2020 at 15:37

1 Answer 1

0

You are just missing the periods that represent a class name in CSS. see below:

  .higher-or-lower {
        margin-left: 200px;
    }

    .first-title {
        color: #ff00ff;
    }
<div class="higher-or-lower">
 <h1 class="first-title">Higher or lower?</h1>
 <h2>Choose between higher and lower</h2>
 <p>Is the number higher or lower then the previous</p>
</div>

Not the answer you're looking for? Browse other questions tagged or ask your own question.