Build a Tribute Page: CSS on the example webpage

In the CSS of the example webpage:

html,body{
  font-family:"Trebuchet MS", Helvetica, sans-serif;
  text-align:center;
  min-width:260px;
  color:#333;
}

why apply the same style for both the html and body elements?

1 Like
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <link href='http://fonts.googleapis.com/css?family=Open+Sans' rel='stylesheet' type='text/css'>
    <style>
    html {
          font-size: 10px;
          font-family: 'Open Sans', sans-serif;
          background-color: #00539F;
        }
    h1 {
          font-size: 60px;
          text-align: center;
        }
    p, li {
          font-size: 16px;  
          line-height: 2;
          letter-spacing: 1px;
        }
    body {
          width: 600px;
          margin: 0 auto;
          background-color: #FF9500;
          padding: 0 20px 20px 20px;
          border: 5px solid black;
        }
    h1 {
          margin: 0;
          padding: 20px 0;  
          color: #00539F;
          text-shadow: 3px 3px 1px black;
        }
    img {
          display: block;
          margin: 0 auto;
        }
    </style>
</head>
<body>
   <h1>Mozilla is cool</h1>
    <img src="https://raw.githubusercontent.com/mdn/beginner-html-site-styled/gh-pages/images/firefox-icon.png" alt="The Firefox logo: a flaming fox surrounding the Earth.">

    <p>At Mozilla, we’re a global community of</p>
    
    <ul> <!-- changed to list in the tutorial -->
      <li>technologists</li>
      <li>thinkers</li>
      <li>builders</li>
    </ul>

    <p>working together to keep the Internet alive and accessible, so people worldwide can be informed contributors and creators of the Web. We believe this act of human collaboration across an open platform is essential to individual growth and our collective future.</p>

    <p>Read the <a href="https://www.mozilla.org/en-US/about/manifesto/">Mozilla Manifesto</a> to learn even more about the values and principles that guide the pursuit of our mission.</p>

</body>
</html>

:grinning: A good example that will solve your doubts, about html and body. Luck!!

1 Like

I understand you can, for example, set different background colors for the html and the body, but why apply the same style to both, like in the tribute page example? Doesn’t the body element inherit all the styles from the html element anyway?

Everything except min-width does get inherited by the body in this case.

If you look up the CSS property you can see which are inherited and which are not (on MDN it is usually below the Specifications Section at the bottom of the page).

You can also force the child to inherit using the inherit keyword.

body {
  min-width: inherit;
}