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

Hashim Warren
seal-mask
.a{fill-rule:evenodd;}techdegree
Hashim Warren
Front End Web Development Techdegree Student 1,207 Points

Is it possible to use CSS to make elements at the bottom of my HTML appear at the top, like navigation?

If I organize a page in HTML with the navigation in the middle:

<body> <nav> <footer>

Is it possible to use CSS to make it appear in a browser with the navigation on top:

<nav> <body> <footer>

I Googled around for this but could not find an answer.

3 Answers

Jose Fremaint
Jose Fremaint
2,885 Points

Replace 0 with the pixels you want.

#element {
     position: absolute;
     top: 0;   
}

Sure! Just be sure to use absolute positioning. Still, though, why not move your nav elements to the top of the HTML document? It would be much easier to read and way more meaningful.

You can technically add your elements in whichever order you like. With CSS you can position it anywhere on the website. If you don't place the navigation at the top, make sure you comment the markup well, that will make it easier for you to read and for others to know where the actual navigation element is located in you HTML file. Placing your nav element on the top will make it a lot easier to maintain later on.