Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member

Styling the navigation

From: Preparing CMS Web Graphics and Layouts Using Open Source Tools

Video: Styling the navigation

Most content management systems will write their navigation bars out as an ordered list. Even if you want that navigation bar to go horizontally, you still have an unordered list or a bulleted list, as it's also called, to work with. So let's go ahead and set that up for our navigation. We'll get rid of our default text there and we'll put it in a bulleted list. So we'll have Home, we'll have About, we'll have Contact.

Styling the navigation

Most content management systems will write their navigation bars out as an ordered list. Even if you want that navigation bar to go horizontally, you still have an unordered list or a bulleted list, as it's also called, to work with. So let's go ahead and set that up for our navigation. We'll get rid of our default text there and we'll put it in a bulleted list. So we'll have Home, we'll have About, we'll have Contact.

This may go on for a while. Site Map. I am not going to worry much that the links here match up exactly with the comp, because ultimately, this navigation bar is going to be coming from the content management system and the text that I am typing in right now is just a placeholder. It's going to get deleted. We're just sort of putting it here so that we can style it, so that when we transport this design over to the database in the content management system, we've at least done some of the work to getting that navigation bar looking good.

So there is our bulleted list. I've just put in four items. I am going to turn them all into links now. If you'll highlight the text and click the link icon. I am just going to type in a pound sign. That's enough to create a link. Obviously it doesn't go anywhere if you click it, but since this is placeholder text, that works just fine. And I am going to repeat the process for all four links here. Okay! So our first problem is we need to get this to not look quite so much like a bulleted list.

We're going to start by removing the bullets from the list itself, then we'll float our individual navigation items out horizontally and add a little padding, and then we'll go ahead and style them to be white and in the Georgia font and not underlined. All right, so of course all of that is CSS work, so I am going to click on the CSS icon and I am going to make a new style and that style is going to be #nav ul.

That's because I'm working with the unordered list that happens to live within the div with an ID of nav. If I was making a bulleted list in the content area, I'd probably really want the bullets. So this is an exception to the overall rules for the stylesheet. So we'll create that rule. One of the first things that we probably want to do is to get rid of the bullets. Under the Lists tab, we can set our List Style Type to none, which will get rid of all of the bullets.

Unordered lists also have either margin or padding built-in around them, and it depends on the browser as to which one it is. So in our Box we'll set our margins and our padding to 0 for the top and the right and the bottom and the left. So now you can see we have a list of links and they're all nice and tightly to the side of that navigation bar.

You may also want to sort these styles so that your #nav ul style is close with the nav style, just to make your stylesheet a little easier to read. So I am going to going to nudge that up the list. We're going to make another rule now. This one is going to be called #nav li. That's for the List Item itself and for the #nav li, which once again I'll move up just under the ul. I am going to set them to float left.

See how that puts all the links all smudged together on a single line? That's great! At least now it's going horizontally, but the spacing is all wrong as you can see. So let's put some padding along these. We'll put some left padding. Let's say it's 2 ems. That'll give us good separation between those links. Let's also give it a little bit of top padding. Let's call it 18 pixels and see what happens there. Now at least we have the links in the center of the navigation bar, so we're doing well.

Now I am going to create another style. This one is going to be called #nav a:link, #nav a:visited. So this tells me that for all links unvisited that are within the nav div and all visited links that are within the nav div, do the following. I could've just said #nav a for the generic A link.

However, sometimes that styling method doesn't necessarily work correctly in all browsers and in all situations. So I like to be a little bit more specific when creating nav link styling. And once again I am going to move that up the list. Now what we need to do is we need to make these links white, we need to make them Georgia, and we need to remove the underlines. So we can do all of that in the Text tab. So we're going to set these to be once again Georgia, Times and Serif, and we're going to set our color to be white. We'll turn off the underlines.

So that's looking pretty good. That's a pretty good match to the comp. We'll say okay and we'll save our page and let's put it in the web browser and see how we're doing. Note that we have our navigation bar and our links. Everything is looking great. One thing we might want to add is when we roll over with a link, maybe we want it to change color. That's a nice effect! So let's go ahead and add that. Back to our CSS box and we'll make a new rule.

This one will be called #nav a:hover. And I will go ahead and move that up with my other styles, and I am going to set this to turn green when we roll over it, so that color is 8aa635 and I'll say okay. Once again let's save. Let's put it in the browser and now when I roll over the links, they'll turn green.

So our page is looking really good. The top looks great, the nav bar is looking great, we have our columns in place, all the styling done. The only thing we're missing now is the footer, which is the next thing that we'll accomplish.

Show transcript

This video is part of

Start learning today

Get unlimited access to all courses for just $25/month.

Become a member
Sometimes @lynda teaches me how to use a program and sometimes Lynda.com changes my life forever. @JosefShutter
@lynda lynda.com is an absolute life saver when it comes to learning todays software. Definitely recommend it! #higherlearning @Michael_Caraway
@lynda The best thing online! Your database of courses is great! To the mark and very helpful. Thanks! @ru22more
Got to create something yesterday I never thought I could do. #thanks @lynda @Ngventurella
I really do love @lynda as a learning platform. Never stop learning and developing, it’s probably our greatest gift as a species! @soundslikedavid
@lynda just subscribed to lynda.com all I can say its brilliant join now trust me @ButchSamurai
@lynda is an awesome resource. The membership is priceless if you take advantage of it. @diabetic_techie
One of the best decision I made this year. Buy a 1yr subscription to @lynda @cybercaptive
guys lynda.com (@lynda) is the best. So far I’ve learned Java, principles of OO programming, and now learning about MS project @lucasmitchell
Signed back up to @lynda dot com. I’ve missed it!! Proper geeking out right now! #timetolearn #geek @JayGodbold
Share a link to this course

What are exercise files?

Exercise files are the same files the author uses in the course. Save time by downloading the author's files instead of setting up your own files, and learn by following along with the instructor.

Can I take this course without the exercise files?

Yes! If you decide you would like the exercise files later, you can upgrade to a premium account any time.

Become a member Download sample files See plans and pricing

Please wait... please wait ...
Upgrade to get access to exercise files.

Exercise files video

How to use exercise files.

Learn by watching, listening, and doing, Exercise files are the same files the author uses in the course, so you can download them and follow along Premium memberships include access to all exercise files in the library.


Exercise files

Exercise files video

How to use exercise files.

For additional information on downloading and using exercise files, watch our instructional video or read the instructions in the FAQ.

This course includes free exercise files, so you can practice while you watch the course. To access all the exercise files in our library, become a Premium Member.

Join now "Already a member? Log in

Are you sure you want to mark all the videos in this course as unwatched?

This will not affect your course history, your reports, or your certificates of completion for this course.


Mark all as unwatched Cancel

Congratulations

You have completed Preparing CMS Web Graphics and Layouts Using Open Source Tools.

Return to your organization's learning portal to continue training, or close this page.


OK
Become a member to add this course to a playlist

Join today and get unlimited access to the entire library of video courses—and create as many playlists as you like.

Get started

Already a member?

Become a member to like this course.

Join today and get unlimited access to the entire library of video courses.

Get started

Already a member?

Exercise files

Learn by watching, listening, and doing! Exercise files are the same files the author uses in the course, so you can download them and follow along. Exercise files are available with all Premium memberships. Learn more

Get started

Already a Premium member?

Exercise files video

How to use exercise files.

Ask a question

Thanks for contacting us.
You’ll hear from our Customer Service team within 24 hours.

Please enter the text shown below:

The classic layout automatically defaults to the latest Flash Player.

To choose a different player, hold the cursor over your name at the top right of any lynda.com page and choose Site preferencesfrom the dropdown menu.

Continue to classic layout Stay on new layout
Exercise files

Access exercise files from a button right under the course name.

Mark videos as unwatched

Remove icons showing you already watched videos if you want to start over.

Control your viewing experience

Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.

Interactive transcripts

Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.

Are you sure you want to delete this note?

No

Your file was successfully uploaded.

Thanks for signing up.

We’ll send you a confirmation email shortly.


Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

Keep up with news, tips, and latest courses with emails from lynda.com.

Sign up and receive emails about lynda.com and our online training library:

Here’s our privacy policy with more details about how we handle your information.

   
submit Lightbox submit clicked
Terms and conditions of use

We've updated our terms and conditions (now called terms of service).Go
Review and accept our updated terms of service.