Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

CSS CSS Layout Basics Controlling Layout with CSS Display Modes CSS Display Modes Challenge

Ashish Jain
Ashish Jain
6,319 Points

please help me in this question

I am posting the link for this question. please let me know the answer.

https://teamtreehouse.com/library/css-layout-basics/controlling-layout-with-css-display-modes/css-display-modes-challenge

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

header {
  text-align: center;
}
.logo {
  width: 110px;
  margin: auto;
}

.main-nav li{
  display:block;

}
index.html
<!DOCTYPE html>
<html>
<head>
    <title>Getting Started with CSS Layout</title>
    <link href='https://fonts.googleapis.com/css?family=Varela+Round' rel='stylesheet' type='text/css'>
    <link rel="stylesheet" href="page.css">
    <link rel="stylesheet" href="style.css">
</head>
    <body>
    <div class="container">
        <header>
            <img class="logo" src="city-logo.svg" alt="logo">
            <ul class="main-nav">
                <li><a href="#">Ice cream</a></li>
                <li><a href="#">Donuts</a></li>
                <li><a href="#">Tea</a></li>
                <li><a href="#">Coffee</a></li>
            </ul>
        </header>
    </div>
    </body>
</html>

3 Answers

Jamie Reardon
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Jamie Reardon
Treehouse Project Reviewer

You haven't used the correct display mode for the list items. You have used block which is the default behaviour for list items so this doesn't change anything. The answer is in the question with a hint: "Use the display value that generates a block element that flows with surrounding content."

That type of display mode would be inline-block.

Inline-block allows elements to layout side by side, while also allowing to set width, height, top and bottom margin/padding values.

Ashish Jain
Ashish Jain
6,319 Points

first question i was able to do. I am stuck at the second question,

Richard Verbraak
Richard Verbraak
7,739 Points

Hey

You want to set main-nav to display inline block like this. The first question was about targetting the li's of main-nav now you target the .main-nav itself and set it to inline-block.

.main-nav {
  display: inline-block;
}

The next one wants you to target the logo class and set it to display: block; so that the margin: auto actually takes effect.

Ashish Jain
Ashish Jain
6,319 Points

I did the same thing. but it is showing answer as incorrect. the code to the second question that I wrote:

header { text-align: center; } .logo { width: 110px; margin: auto; } .main-nav { display:inline-block; }

Richard Verbraak
Richard Verbraak
7,739 Points

As Kris said, keep the code you added from previous steps otherwise you get errors.

Ashish, did you keep the code in task 1 for task 2? There is a note in the challenge 'Important: In each task of this code challenge, the code you write should be added to the code from the previous task.'