Start learning with our library of video tutorials taught by experts. Get started
Viewers: in countries Watching now:
CSS gives Web designers control over the appearance of their web sites by separating the visual presentation from the content. It lets them easily make minor changes to a site or perform a complete overhaul of the design. In CSS Web Site Design, instructor and leading industry expert Eric Meyer reviews the essentials of CSS, including selectors, the cascade, and inheritance. The training also covers how to build effective navigation, how to lay out pages, and how to work with typography, colors, backgrounds, and white space. Using a project-based approach, Eric walks through the process of creating a Web page, while teaching the essentials of CSS along the way. By the end of the training, viewers will have the tools to master professional site design. Exercise files accompany the training videos.
In this video we're going to talk about borders and elements. Borders are a way of providing sort of a more concrete separation between pieces of a design and what we're going to do here, you can see, this is the page as it now stands and if we compare this to the designers comp that was given to us there are a few borders here is practically that we don't have yet. For example underneath The Legendary Origins of Tea, there's a separator. Also under the Labrador tea, heading over in the sidebar and the tea of the day box, there are these bottom borders.
There is one other set of borders in this design and that's the separators between the links in the navigation bar across the top. This is the sort of thing you might think yourself oh, look it's a vertical pipe character, and I can just type that off of my keyboard and you can, if you're willing to insert those characters into your document source, but we can do with CSS, just using orders, and the first place that we're going to take care of this is with the content h2 where we're going to put a bottom border on it, if you recall it was what looked like a one pixel solid border and it had a green color that we got from the designer as being B0D742 and having done that, if we flip back over to Firefox and hit Reload, there's that border, just like we saw in the comp. Now this is not the right separation yet from the text, it's a little too close to the texts. That we're actually going to fix in one of the next couple videos when we'll about Padding.
But at the moment we've got the border that we want. Adding a border to the h4 under the tea of the today is similarly simple, you say. Now in this case, we can actually get away with saying quarter one px solid, because what we want is we want a white border then, that way border matches the text color and we can make the assumption that the border under heading should always match its text color so by leaving off the text color in our code and just saying border bottom 1px solid, we get the effect and sort of future proof ourselves.
Now the last thing is going to be, the certainly more interesting one and that's the border separators between the links in the comp. What we have if we look at the markup is we have a bunch of, well we have an ordered list with list items, and usually those list items contain various links. So what we're going to do is on these navigation link list items is create right borders, but a border on each right one, so again, using a color that we got from asking the designer. A right border on each of these list items of one pixel solid and a given color, we hit Reload, you can see that those borders are starting to appear.
Now, it's not exactly like it looks in comp yet, because we still have to do things like add padding, not only to the list items here, but also to the order list in which they sit, so that we can make the purple area of the navigation bar bigger, but this is a start. You can already see that we have these vertical line separators between each of these links. But there's one more than we want. Over to the right edge of contact us, we have a border that we're not looking for, it doesn't exist in the comp. So we're going to need to do little bit of a structural trick.
You'll notice if you look closely, the first list item in the list has a class of first and the last list item in the list has a class of last. We're going to use that to our advantage. Right here by saying navlinks li.last, border-right 0. That's going to effectively switch off the border there. It's going to do that in a couple of ways, but we're going to reload, we notice that separator comes away. What we've done, we could have set border right 0 none, like that. Basically border right 0 is setting the right borders width to be zero, but it's also by default setting the right borders style to be none as opposed to solid and if a border doesn't have a style if the border style of a border is none, then it has no width or color for that matter it simply ceases to exist so, you can say border right zero and know that if that's going to effectively switch off a given order or you could say border none, border-right none and that will give you the same effect. So, again whichever one you find you like better is the one that you should stick with.
There are a number of border styles, besides none and solid, things like dotted and dashed and groove where pretty much each of them does what you would expect given their naming. So you can look into those in more detail, if you like or play around with them. The one that's a little interesting, we're just going to take a quick look at what is double. If you look at the border underneath the h2 now it's three pixels wide, but it's a double border so there's a space between the two, between two lines in the border.
The interesting bit here, the reason I bring this up is that you can't control the ratio of the border, the two lines widths, to the width of the gap between them. So if I were to say border and if I were to say the border bottom here 4px double, I don't know if the gap is going to get bigger or the inner one of those lines will get bigger or the outer one of those lines will get bigger and more to the point, there's no way for me to be sure that it will be consistent across browsers. Odds are that it won't. So, generally, if someone is using a double border they're doing it this way three pixels wide, because they can be pretty darn sure that they are going to get a one pixel line, one pixel gap and a one-pixel line and be done with it.
Another interesting question is what happens if you say, one pixel double. Some browsers have been known to simply drop the gap between the two lines, but anyway, that's the one border style that can get a little interesting. The others are fairly straightforward like I say, dotted, dashed and so on and you can look into those in more detail, should you so desire.
There are currently no FAQs about CSS Web Site Design.
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
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.