Start learning with our library of video tutorials taught by experts. Get started
Viewed by members. in countries. members currently watching.
In XHTML and HTML Essential Training, Bill Weinman helps designers and coders understand XHTML and HTML. In the process, Bill covers document structure, block and inline-level tags, floating images, controlling white space, phrase and font markup, and tables and frames. He even provides a good introduction to CSS. Bill offers step-by-step guidance for building a complete working web site. Exercise files accompany the course.
Now, we are going to begin building the website and all of the graphics and all of the design has already been provided for us. Our task is to take the assets that we've been given and create a website that looks like this. As a beginning place, we have our exercise files and in the chapter 02-header folder, we have a beginning and an ending. Ending is what the file is supposed to look like when we are all done and we also have a beginning and an ending CSS and these are loaded up in our editor.
So, the first thing that we're going to do is we're going to save both of these files as a different name. The point of this is so that we can do our edits and work on the file and not write over the original files that came with the exercise files, so that we have our beginning place still if we need to go back to it. So, the first thing we are going to do is save this file as, I'm going to call this one header.html because over the next couple of lessons we are going to be building the header portion of the website and for the CSS file, we'll do a Save As.
CSS file is going to be called main. css because that's how it's referenced in all the HTML files. So, all the HTML files can share this main.css and in that way we are not overwriting our original files and we can go back, if we need to, we can do the exercises over again, if we need to and we still have our starting place. All right. So let's get started. The first thing we are going to do here in the header.html file is change the title and it will be Welcome to Groundswell and we are going to link in the external CSS.
So, this is the Link tab. We've seen this before, because in the head section of the XHTML, attributes are href, which gives the location of the CSS file, and the rel, which is the relationship and that's called style sheet and the type, which is text/css. We have this little shorthand for closing off a tag that does not have an end tag and we'll go ahead and save this and load it up in the browser. We'll go here and we'll drag it from the Explorer window and there we have it, Welcome to Groundswell, and the content here.
Now, let's go ahead and add some style using the style sheet. First thing we are going to do in the style sheet is we are going to put in our global default styles. So, we are going to start with a comment. I always like to have comments separating the sections of the CSS, call this global styles. Comments in CSS are separated by these /* and */. This syntax is taken from the C programming language where comments are done like that. Go ahead and start with the body.
I'll like to put a few things in the body. I'll like to give it a default font family, even though it will probably never be used. It's just a good practice. In this case, we'll give it a sans- serif font family and we'll set up the backgrounf. And the background here has two parts to it. So, we're using the shortcut in CSS. We are doing both the background color and the background image at the same time and so we have bbb, which is a light gray color that kind of matches the image itself.
If for some reason the image can't load or somebody has got images turned off on the browser, it'll still look reasonable. And the url for the page background graphic, you will notice that it starts with these two dots. That means go up a directory. The reason for this is that in the external style sheet, the image location is relative to the style sheet itself. It's not relative to the document and so if we look at our site organization, here we have the document itself, this header.html, and there is a CSS directory which is where the CSS file is and then there is an images directory which is next to the CSS directory in the tree.
So, from the CSS directory, you need to first go up a level and then go back into that images in order to find the banner.jpg. So, that syntax looks like this with the dot, dot and then the path from there. So, first it goes up a directory and then it goes into the images directory and then the page background. We'll set Margin and Padding to zero, and this is the syntax that says it's a shortcut for all the margins, top, right, bottom, left setting that to zero and likewise for the padding.
What this does is it allows us to have everything butt up against the borders of the browser itself. If you look at the website, the top of the website is all the way up at the top and then the actual content is centered on the page. This allows us to have the border and the margin set to zero, so there is no space there at the top. Then we'll save this and we'll move on like that, save as I go along. We're going to do some default margins for all of the text block elements like p and h1 etcetera.
And this is another CSS shortcut, when you just have two values in here. Remember normally you put in four values, which would be top, right, bottom and left, which goes clockwise around the circle. But if you just put in 2, then the first one is the top and the bottom and the second one is the right and the left. So, we have 1ex top and bottom, and 1em right and left and that gives us just a nice little default and you will see that looks like this. Again, we are not going to use these defaults but it's nice to have them just in case.
So, it gives us just a nice little spacing at the top and spacing at the left and there is our page background, that lovely little flowered pattern. Go ahead and enter some more defaults. So, this is the default for all the tables and again, this is going to be a table-based layout. You'll notice the border-collapse, this is the one that we haven't seen before, border-collapse. It changes the table layout model. There are two layout models. There are border-collapse to collapse and border-collapse to separate. Separate is the default and interestingly that will work in all browsers except Internet Explorer.
If we leave that to its default value or set it to separate, Internet Explorer will break up some of our tables, not all of them, the layout will look disjointed and so we just set it to collapse, which worked in all the browsers that I have tested. Again, like all of this, you want to test this in any browsers that matter to you. I'll go ahead and save and go on. I'm going to continue to format the tables. I'm going to set our defaults for the rows and columns. And again, because we are doing layout with tables, we want to have some reasonable defaults for all this. margin 0, padding 0.
That allows us to have content that goes up against the edges of the table cells, like we need to do for things like these images, which if you remember, this is one image and this is a separate image here and it's in a separate table cell and then our content is down here, and we want all of this to butt up to each other without separation. And so that margin zero and padding zero in the table cells. That allows us to do that. So that's our defaults and in the next lesson, we are going to start putting in the header content.
Find answers to the most frequently asked questions about XHTML and HTML Essential Training.
Here are the FAQs that matched your search "":
Sorry, there are no matches for your search ""—to search again, type in another word or phrase and click search.
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.