CSS CSS Basics Understanding Values and Units Em and Rem Units

Seketha Peak
Seketha Peak
1,450 Points

what is 20px to ems I have tried all the answers I believe is right need a little help

on this em question and I don't know where I am going wrong....just a little assistance is needed.

style.css
/* Complete the challenge by writing CSS below */

header {
  font-size: 29px;
}

.title {
  font-size: 26px;
}

h1 {
  font-size: 90px;
}

h2 {
  font-size: 3.3125em;
}

h3 {
  font-size:1.250em;
}
index.html
<!DOCTYPE html>
<html>
  <head>
    <title>Lake Tahoe</title>
    <link rel="stylesheet" href="page.css">
    <link rel="stylesheet" href="style.css">
  </head>
  <body>
    <header>
      <span class="title">Journey through the Sierra Nevada Mountains</span>
      <h1>Lake Tahoe, California</h1>
    </header>
    <div class="main-content">
      <p>
        Lake Tahoe is one of the most breathtaking attractions located in California. It's home to a number of ski resorts, summer outdoor recreation, and tourist attractions. Snow and skiing are a significant part of the area's reputation.
      </p>
      <a href="#">Find out more</a>
      <h2>Check out all the Wildlife</h2>
      <p>
        As spawning season approaches, the fish acquire a humpback and protuberant jaw. After spawning, they die and their carcasses provide a feast for gatherings of mink, bears, and Bald eagles.
      </p>
      <a href="#">See the Wildlife</a>
      <h3>From Tents to Resorts</h3>
      <p>
        Lake Tahoe is full of wonderful places to stay. You have the ability to sleep in the outdoors in a tent, or relax like a king at a five star resort. Here are our top three resorts:
      </p>
    </div>
    <footer>
      <p>All rights reserved to the state of <a href="#">California</a>.</p>
      <a href="#top">Back to top &raquo;</a>
    </footer>
  </body>
</html>

2 Answers

Emre Karakuz
Emre Karakuz
9,162 Points

Look at this code example :

<body>   <!-- Consider that its font-size is set to 1.5em -->
     <h1>Header</h1>    <!-- Consider that its font-size is set to 2em -->

    <p>A paragraph explains smthng...</p>   <!-- Consider that its font-size is set to 1,5em --> 
</body>

to find font-size of the <p>tags, multiply its own size property with its parent elements font-size.

<p> tags have 1,5em, its parent <body> has 1.5em ; font-size of <p> : 1,5em*(1,5em) = 2,25em (36 pixels)

for <h1>

<h1> has 2 em, its parent <body> has 1,5em ; font-size of <h1> : 2em*(1,5em) = 3em (48 pixels)

Try to convert px units to em's. Challenge wants you to do that

Alex Koumparos
MOD
Alex Koumparos
Python Web Development Treehouse Moderator 33,502 Points

Hi Seketha,

Oddly, the problem is with the precision of your font-size. The system rejects 1.250 but 1.25 passes the challenge.

Cheers

Alex