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

How can I put elements side by side.

How can I put elements side by side, I want to select anchor elements from inside of my nav to be side by side.

here's the link to my code- https://w.trhou.se/9x44qvlt0c

Directions After You Click The Link:

The file index.html has the nav which I want to be styled side by side and If you go to my CSS folder you'll see main.css and that's the code i'm using for index.html

3 Answers

I found your problem.

You need to add this :-

nav li { display:inline-block; }

Thank you your the best you have no idea how long I've been trying to figure this out.

Thomas Fildes
Thomas Fildes
22,687 Points

If you'd like the links to be horizontally side by side (inline) then all you have to do is create a new selector in your css which selects the <li> items in your <nav> and then type out display:inline-block as shown below:

nav ul li { display: inline-block; }

Hope this helps Christopher.

I did a long form version so that you can comment out each selector to see how it works with developer tools starting with the list items.

nav,
nav ul,
nav li {
       display: inline-block;
}