Start learning with our library of video tutorials taught by experts. Get started

Up and Running with HTML
Illustration by

Examining the document head


From:

Up and Running with HTML

with James Williamson

Video: Examining the document head

Directly after the opening html tag, you'll find a document's head. Now the head element is where you'll place information about the document, references to external scripts and styles, and additional instruction to the browser about how the document should be rendered. To add the head to our document I am going to open up the structure.htm file, which can be found in 02_03 folder. To be honest with you though, if you're coming directly from the last exercise and you still have that file open, you just keep it open, because we are simply building on the last file that we have did. You can see, as a matter of fact, in this one the only thing we have is the document type declaration that we built in our last exercise.
Expand all | Collapse all
  1. 2m 12s
    1. Welcome
      55s
    2. Using the exercise files
      1m 17s
  2. 29m 30s
    1. Learning HTML
      2m 47s
    2. Choosing a code editor
      5m 2s
    3. Exploring basic HTML syntax
      8m 18s
    4. Do I need to learn HTML5?
      5m 6s
    5. Exploring HTML references
      8m 17s
  3. 35m 40s
    1. Exploring an HTML document
      5m 19s
    2. Working with doctype declarations
      4m 3s
    3. Examining the document head
      8m 20s
    4. Looking at the document body
      3m 21s
    5. Adding document structure
      8m 52s
    6. Lab: Coding a basic page
      3m 9s
    7. Solution: Coding a basic page
      2m 36s
  4. 1h 23m
    1. How does HTML format text?
      5m 51s
    2. Adding headings
      7m 24s
    3. Formatting paragraphs
      4m 54s
    4. Controlling line breaks
      3m 50s
    5. Creating lists
      10m 37s
    6. Emphasizing text
      6m 42s
    7. Displaying special characters
      5m 8s
    8. Controlling whitespace
      4m 35s
    9. Inserting images
      9m 20s
    10. Lab: Controlling page content
      13m 57s
    11. Solution: Controlling page content
      10m 55s
  5. 31m 54s
    1. Linking to pages within your site
      6m 45s
    2. Linking to external pages
      3m 2s
    3. Linking to downloadable resources
      2m 25s
    4. Linking to page regions
      8m 0s
    5. Lab: Creating Links
      5m 57s
    6. Solution: Creating Links
      5m 45s
  6. 40m 27s
    1. Examining basic table structure
      5m 10s
    2. Adding content to tables
      6m 20s
    3. Setting table attributes
      7m 42s
    4. Adding table captions
      4m 3s
    5. Defining table headers
      2m 13s
    6. Making table data accessible
      5m 46s
    7. Lab: Building tables
      4m 13s
    8. Solution: Building tables
      5m 0s
  7. 43m 23s
    1. Understanding the relationship between HTML and CSS
      4m 58s
    2. Creating inline styles
      4m 53s
    3. Exploring the style element
      5m 13s
    4. Basic font styling
      9m 24s
    5. Changing color
      4m 55s
    6. Taking styles further
      5m 24s
    7. Lab: Controlling basic styles
      5m 10s
    8. Solution: Controlling basic styles
      3m 26s
  8. 5m 44s
    1. Next steps
      2m 56s
    2. Additional resources
      2m 48s

Watch this entire course now—plus get access to every course in the library. Each course includes high-quality videos taught by expert instructors.

Become a member
please wait ...
Up and Running with HTML
4h 32m Beginner Oct 19, 2012

Viewers: in countries Watching now:

This course is designed to quickly lead you through the steps of building an HTML website, from creating a new page to building links and tables. Author James Williamson simplifies the coding process, with straightforward steps you can recreate on your own. The course explains the basic structure of an HTML document, shows how to add text and images, and introduces font styling with CSS. James also offers a bonus design challenge at the end of each chapter, where he asks you to think of a solution before offering his own.

Topics include:
  • Choosing a code editor
  • Coding a basic page
  • Adding headings
  • Formatting paragraphs
  • Creating lists
  • Inserting images
  • Linking to internal and external pages
  • Linking to downloadable content
  • Building tables with headers and captions
  • Creating inline CSS styles
  • Changing the color and font of your text
Subjects:
Web Web Design Web Development
Software:
HTML
Author:
James Williamson

Examining the document head

Directly after the opening html tag, you'll find a document's head. Now the head element is where you'll place information about the document, references to external scripts and styles, and additional instruction to the browser about how the document should be rendered. To add the head to our document I am going to open up the structure.htm file, which can be found in 02_03 folder. To be honest with you though, if you're coming directly from the last exercise and you still have that file open, you just keep it open, because we are simply building on the last file that we have did. You can see, as a matter of fact, in this one the only thing we have is the document type declaration that we built in our last exercise.

Before we can add the head element to our HTML file, we have to have an HTML file, and we don't have one yet. So what I am going to do is directly after the doctype declaration, I'm going to go down to the next line and I am just going to type in an opening html tag. And then what I'll do is I'll go down on the line below that and I'll close the html tag out. So we just have an opening and a closing a html tag. That identifies this as being an HTML document and now we are free to sort of move on and add all the content to it. Before we do that, however, I am going to go back to the html tag and I am going to add an attribute to it.

So what I am going to do is click just inside the opening html tag right after the characters html tag, and I am just going to hit the spacebar to give myself a little bit of whitespace between the characters html and the attribute itself. And I am going to do the language attribute, and that is lang= "en" for English. Now what that's going to do is it's going to tell the browser that, hey, this entire HTML document is in English. Now if I've an individual paragraph for example that is in Spanish or French or Italian, I could indicate that at the paragraph level as well.

That's helpful for a number of reasons: translators will know which language you are looking at, screen readers will know how to enunciate or pronounce certain words. It's important you do this. It's not essential. It's not something you have to do for every HTML file you work with, but it's nice practice. I'll go ahead and save that and now we are ready to add our head. So what I am going to do is again, I am going to go up to the opening html tag. I am going to go right inside that and I am going to go ahead and open up the head. And then directly below that, I am going to go ahead and close the head tag.

Now you'll notice that I'm beginning to show you a pattern that I use as I author any code, really, that I'm working on. You can pick up this practice or you can choose not to adopt it. It's totally up to you. This is a personal preference of mine. If I open up a tag, even if there is going to be a lot of content inside that element, I'll go ahead and close that element before I start adding content. That does two things for me. The first is, it really kind of just shows the simplicity of what I'm building, because this head might have hundred lines of code in it, but it's still just a head element.

So it sort of identifies those basic structural elements first. The second thing that it does for me is it ensures that I close the element properly. With HTML it's not as bad as with some other languages, but whenever you open up an element and you begin adding a bunch of stuff, it's really easy, say, thirty minutes on down the line to forget that you've opened up the head tag in the first place and you just forget to close it. That happens quite often, and it can result in some serious syntax errors. So I advise you to sort of pick up that practice and it'll help prevent syntax errors on down the line.

I mentioned earlier that inside the head element of the document you're sort of putting the information about that document. You know, what is this document, what's the subject of it, are there any links to external scripts that you need me to execute or styles that you want me to show, that sort of thing. So, all the invisible stuff that goes either to give more information about the file or make the page work are going to go inside the head. So let's go ahead and just throw in a couple of simple things that we typically find in the head of an HTML document. Inside the head tag making sure that I'm inside the opening and closing tags, I am going to create a blank line, and the first thing that I am going to do is I am going to add a character set meta tag.

So meta tags are very important. I am going to go ahead and open up a tag, and I am just going to type in the word meta. So this is a meta tag, and there are several different types of meta tags that you can use. You can use meta tags to write a description of the page. We will do that in a minute, to add keywords to the page. You can use the meta tag to describe the viewport, or how large the window should be, which is helpful for mobile devices and things like that. So there are all sorts of things that you can do with meta tags, so I really recommend researching these as much as you can. The meta tag that we are going to use is going to use the character set attribute, and you can see it's the first one that's coming up here in my code hinting.

I am just going type in charset, character set. And then inside the equals I'm going to type in "utf-8," so that's the encoding that I am going to use for this particular character set. Typically, that's the one that everybody's going use, unless you are using a different language that requires a different character set. And it's very, very important that you specify this. In most cases your web server will send out a header that has a character set encoding in it, but in case it doesn't, it's very important for the HTML page do that.

So that's the first thing that you should do inside the head of your document to make sure that one of the first things the browser encounters is the instructions about which character set to use. So after that I am going to go down and I am going to add another meta. And in this case, I want to do a meta that has a description for the page. So I am going to type in meta. Once again, this time I am going to use name instead of character set, and the name for this one, in quotation marks, is going to be description. So I'm just basically letting the browser know, or any of these user agents know, that this was going to be description of the page contents. And then after the name attribute, I am going to go ahead and give it a content attribute, and this is where I actually pass the description itself.

So again, in quotation marks here, I am going to type in "A page for exploring basic HTML syntax." So this just sort of describes what the page is. And then finally, I am going to close using the right angle bracket. So you'll notice that meta tags don't have a closing tag. They are not optional. It just doesn't have one, so you don't need them at all. So you can see meta name= "description" content= whatever I want my description to be. Now, what's the point of this? Well, it's very helpful for search engines. When they start displaying search results, they'll actually go into the meta description tag and display your content there for a brief description of the page.

So it's very helpful here to be descriptive in terms of what is on this page and how you'd want is to display. There is also another meta that you can use for keywords. For the most part, search engines sort of ignore them, because people have used them for so long. So there is dubious value in doing keywords now, except for the fact that you could sort of type in keywords that means something to you and within your blog or some like that, you can actually use that to do an intelligent search or retrieve your own things for keywords or just a way of indexing the page. So they're still valuable, but they're not valuable anymore in terms of search engines.

I am going to do one more thing within the head of the document, so I am going to hit Enter and go down to the next line, and here I am going to add a title. So we are going to use the title element, and to do the title, you do an opening tag, you'll type in what you want the title of the page to be, and then you'll close that opening tag. And for this one, I am just going to type in the BASIC HTML document. You'll notice that that text is surrounded by the opening title tag and then the closing title tag. So this is like the one thing that goes in the head that is just visible for other people.

If we save this file, for example, and then I were to preview this file, say, in one of my browsers-- so I preview this page on a browser, you can there is really nothing on the page here. It doesn't even have a body to it. But what we do see, up in the title bar of the tab here, is BASIC HTML document, so that's one of the places that the title will show up. And other user agents will use the title in different ways to represent the page, so it's a very important part of any HTML page. You need to make sure there's a title within the head of the file. You can also write local styles and scripts within the head, as well as adding references to external styles and scripts that are going to be used by the page.

Now we are going to explore adding styles to the head of our document a little later on in the course, but for right now, we're done with the basic structure of the head of our document.

There are currently no FAQs about Up and Running with HTML.

 
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.
Upgrade now


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 Upgrade now

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 Up and Running with HTML.

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

Notes cannot be added for locked videos.

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.