New Feature: Playlist Center! Pick a topic and let our playlists guide the way.

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

Building a document header

From: XHTML and HTML Essential Training

Video: Building a document header

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.

Building a document header

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.

Show transcript

This video is part of

Image for XHTML and HTML Essential Training
XHTML and HTML Essential Training

59 video lessons · 80108 viewers

Bill Weinman
Author

 
Expand all | Collapse all
  1. 5m 10s
    1. Welcome
      1m 16s
    2. Using the exercise files
      1m 23s
    3. Choosing a text editor
      2m 31s
  2. 15m 46s
    1. Introducing HTML and XHTML
      2m 53s
    2. Understanding versions of HTML and XHTML
      2m 25s
    3. Exploring a simple XHTML page
      4m 47s
    4. Understanding the structure of an XHTML document
      2m 58s
    5. Understanding document containers
      54s
    6. Creating and using templates
      1m 49s
  3. 42m 4s
    1. Understanding how empty space is formatted in XHTML
      2m 42s
    2. Using paragraph tags
      2m 42s
    3. Aligning paragraphs
      2m 49s
    4. Understanding block-level and inline tags
      1m 24s
    5. Controlling line breaks and spaces
      5m 43s
    6. Formatting text with phrase element tags
      3m 28s
    7. Formatting text with font markup elements
      3m 24s
    8. Adding document structure with headings
      3m 25s
    9. Formatting quotations and quote marks
      2m 19s
    10. Preserving pre-formatted text
      1m 30s
    11. Selecting a typeface
      4m 33s
    12. Selecting a type size
      2m 11s
    13. Using ordered and unordered lists
      5m 54s
  4. 7m 48s
    1. Using inline images
      3m 17s
    2. Flowing text around an image
      2m 4s
    3. Breaking lines around an image
      2m 27s
  5. 22m 34s
    1. Working with hyperlinks
      7m 46s
    2. Using relative URLs
      3m 5s
    3. Specifying a base URL
      2m 4s
    4. Linking within a page using fragments
      4m 28s
    5. Creating image links
      5m 11s
  6. 22m 56s
    1. Introducing tables
      4m 37s
    2. Formatting tables with CSS
      8m 50s
    3. Aligning images with tables
      5m 7s
    4. Reviewing an alternative solution using CSS
      4m 22s
  7. 14m 31s
    1. Introducing frames
      7m 56s
    2. Hiding frame borders
      3m 15s
    3. Creating inline frames using iFrame
      3m 20s
  8. 20m 50s
    1. Introducing forms: part 1
      10m 37s
    2. Introducing forms: part 2
      7m 45s
    3. Using CGI with forms
      2m 28s
  9. 25m 42s
    1. Introducing CSS
      3m 11s
    2. Understanding levels of inheritance
      6m 10s
    3. Learning CSS syntax
      11m 23s
    4. Using units of measure in CSS
      4m 58s
  10. 1h 45m
    1. Comparing table layout and CSS layout
      1m 25s
    2. Exploring the finished web site
      2m 37s
    3. Building a document header
      8m 18s
    4. Placing a banner and a contact button
      8m 13s
    5. Laying out a main menu
      6m 55s
    6. Creating a layout template: main body area
      13m 31s
    7. Creating a layout template: sidebar area
      5m 17s
    8. Creating a layout template: footer content
      4m 46s
    9. Building a main home page: main body content
      11m 24s
    10. Building a main home page: sidebar content
      8m 52s
    11. Creating a page with a menu, graphics, and formatted links
      13m 26s
    12. Creating a page containing an ordered list
      6m 44s
    13. Creating a page containing video
      10m 45s
    14. Touring the finished site
      3m 45s
  11. 53s
    1. Goodbye
      53s

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

Are you sure you want to delete this note?

No

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.