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

Adding headings

From: Up and Running with HTML

Video: Adding headings

The first major formatting elements that we're going to take a look at are headings. Headings are used to structure pages and determine content hierarchies, so let's take a closer look, using the file headings.htm. I've opened that up here, in Komodo. Feel free to open that up in whatever code editor you have. Well, notice that inside the body tag we've got some text here, and I've sort of separated the text into sections, or chunks of text if you will, by placing them on separate lines. So you can kind of see where those Line breaks are denotes a new section of content.

Adding headings

The first major formatting elements that we're going to take a look at are headings. Headings are used to structure pages and determine content hierarchies, so let's take a closer look, using the file headings.htm. I've opened that up here, in Komodo. Feel free to open that up in whatever code editor you have. Well, notice that inside the body tag we've got some text here, and I've sort of separated the text into sections, or chunks of text if you will, by placing them on separate lines. So you can kind of see where those Line breaks are denotes a new section of content.

It's easy for us to sort of look at that and determine that these are new sections of content, but if we were to preview this page in our browser, there's really not a lot going on here to let you know who's who and what's what, and that basically has everything to do with the lack of formatting structure currently within our code. We are going to add some headings, and the first thing I'm going to do is go up to this first line right up here where it says, "Up and Running with HTML" and I'm just going to format that as a top-level heading, or an h1.

We have six different levels of headings that we can use, and they range from h1 all the way down, of course, to h6. So if I save this and then wrap the second one in an h2, which of course is our second-level heading--and I'll save that and go back to my browser and preview this-- you can see that now there's a little bit more organization, in terms of the content. Up and Running with Html is a top-level heading. Formatting page is the second-level heading.

The browser is going to show us the levels of the headings based upon the size of the text. You'll notice that the h1, for example, is much larger and the h2 is a little bit smaller. Now, that's consistent all the way down. If I go down to the h2 and change this to, say, an h6, which is the smallest-level heading we can have--save that, again, refresh that-- you can see it's tiny. It's actually smaller than the body copy itself. So, browsers are going to sort of denote how important a heading is based upon the size of it, and that really sort of runs us into problems with most people as they start learning HTML, and that is this: the wrong way to approach using headings is to use a heading based upon what size you want it.

It's actually quite common for people to say, okay well, h6 is a little small, so let me go back and try an h3, maybe that will get it done, in terms of how big I want this, and save that and test it. That's much better. It's exactly the size I want it. But what they're doing is they're using headings to control the presentation of that, and that is the absolutely wrong approach to take. You want to develop a strategy around using your headings that's based upon the level of the heading itself and not necessarily the size of it, because, eventually you're going to be controlling that with CSS.

I can make through CSS an h6, actually larger and bigger and bolder than an h1, if I wanted to. So the size really has nothing to do with it; it's all about structuring it properly. So I have some additional headings here. If I took all of these headings and converted them all to h1s, so if I wrapped formatting page content in h1 and then went down to adding headings and wrapped that in h1 as well-- Same thing for using paragraphs, if I came in, wrapped this in an h1, and then, finally Line breaks, and wrap that in an h1.

What this is going to do, if I save this, go back into my browser and refresh, it's going to create all of these different sections for me that are all going to be sized exactly the same. But really, what I'm telling any user agent that parses this page is that these headings all have the same level of importance. And that's really what you ought to consider when you decide how to assign headings to the page: How important is this? One of the things that headings really do for us is to create sections within our content.

As a matter of fact, prior to HTML5, the only sectioning elements that we had in our page were headers. Now, with HTML5 we have some different sectioning elements that we can use, but headings really are still kind of the star of the show when it comes to creating sections within your page. So really think about your document as if you were going to generate a table contents from it, or if you were going to create an outline of that document later on. Do these sections have all the same level of importance? And of course for this document that answer would be no.

Obviously, the most important heading that we're looking at on the page right now would be Up and Running with HTML. After that, Formatting page content kind of is the title of the page whereas Up and Running with HTML is the title of the entire course. And then after that adding headings using paragraphs and line breaks, those do have sort of an equal level of importance, and they're basically subsections within formatting page content. So if you look at it that way, it becomes pretty easy to develop a heading strategy. So if I go back into my code, what I'd want to do is have Formatting page content as a heading 2 and then I'm going to convert all the rest of my headings to a heading 3, or an h3.

So again, the syntax behind these is simply an h, and then the number that you wish to have, and make sure that your opening and closing paragraphs match as far as it goes. That's very important. So if I save that, go back into my browser and refresh this, now that level of importance in the sections themselves are denoted, so it's very easy for a reader to scan the page right now, determine what's the most important content or the most important section of the page or what the page is all about, and then go through the individual sections as well. Now, there are some best practices involved with using headings.

For the most part, you want to limit the number of h1s you have on the page. There are a lot of SEO--search engine optimization-- people out there that will tell you to only use one h1 on a page. Well, there's no hard and fast rule that says that, and as a matter of fact, even Google who really should know about SEO, tells you that you don't get punished for using more than h1 on the page. They are just looking as to whether or not it's being used logically. So if you have two top-level headings that denote two sections of equal importance, there's nothing wrong with doing that; you just need to be logical in your approach to doing it.

The next thing you want to do is you don't want to skip a series of headings. On this page, for example, we're going to an h1 and then to an h2. Well, for these subsections, we wouldn't jump to an h5 or even to an h4. We want to go right down to an h3. The only time that you might change that is when you develop a sit-wide strategy. One of things that you're going to need to do as you plan your sites is you're going to think about the content that shows up on each and every page. Then, based upon that content, you can develop a heading strategy to denote the importance of certain sections.

In that case, one of the things you might think about is, okay, who does this content belong to, in terms of that level? If it is an h4 and you skip over and you will have any of those type of h3s on the page, then that would be fine. But for the most part your structure is going to be consistent like that, and that's one of the best practices that you want to make sure that you're aware of as you start planning your pages. So of course it's very important to establish site-wide rules around the use of headings, especially when you're planning your sites. Be sure to remember that the use of headings on your page should be driven by properly structuring the information and not by the visual formatting requirements of the page's content.

Show transcript

This video is part of

Image for Up and Running with HTML
Up and Running with HTML

49 video lessons · 27268 viewers

James Williamson
Author

 
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

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

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


OK

Course retiring soon

Up and Running with HTML will be retired from the lynda.com library on October 31, 2014. Training videos and exercise files will no longer be available, but the course will still appear in your course history and certificates of completion. For updated training, check out HTML Essential Training in the lynda.com Online Training Library.


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 preferences from 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.