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

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

HTML5 First Look
Illustration by

Ensuring cross-browser structure


From:

HTML5 First Look

with James Williamson

Video: Ensuring cross-browser structure

Our HTML5 layout is now complete. We've tested it in all our browser. We've checked the outline. Everything is good, right? Well, almost. Although most modern browsers handle the new HTML5 semantic elements just fine, and Internet Explorer 9 is supposed to have great HTML5 support, older versions of browsers, most notably Internet Explorer, can have some serious problems rendering your shiny new HTML5 document. So let's take a moment to deal with that before we move on to our next chapter.
Expand all | Collapse all
  1. 3m 56s
    1. Welcome
      1m 1s
    2. Using the exercise files
      1m 50s
    3. Who is this course for?
      1m 5s
  2. 21m 12s
    1. Exploring prior standards
      4m 26s
    2. Why do we need HTML5?
      3m 32s
    3. HTML5 timeline
      4m 24s
    4. Current HTML5 support
      4m 25s
    5. What HTML5 is (and what it isn't)
      4m 25s
  3. 27m 49s
    1. HTML5 vs. HTML4
      3m 25s
    2. New structural tags
      6m 1s
    3. New content tags
      4m 7s
    4. New application-focused tags
      5m 32s
    5. Deprecated elements
      4m 28s
    6. API overview
      4m 16s
  4. 22m 29s
    1. Content models
      5m 33s
    2. Understanding the outline algorithm
      3m 21s
    3. The role of ‹div› tags
      4m 20s
    4. Using ID and class attributes
      2m 6s
    5. DOCTYPE declarations
      4m 16s
    6. Character encoding
      2m 53s
  5. 41m 27s
    1. Basic page structure
      3m 40s
    2. Structuring top-level elements
      7m 30s
    3. Structuring interior content
      8m 42s
    4. Building headers
      9m 11s
    5. Checking document outlines
      5m 46s
    6. Ensuring cross-browser structure
      6m 38s
  6. 27m 53s
    1. New input types
      5m 57s
    2. Setting form autofocus
      2m 53s
    3. Using placeholder data
      4m 4s
    4. Marking required fields
      3m 24s
    5. Working with number inputs
      5m 49s
    6. Using date pickers
      5m 46s
  7. 1h 1m
    1. Canvas overview
      6m 21s
    2. Adding canvas content
      8m 58s
    3. Drawing in the canvas environment
      12m 9s
    4. Drag-and-drop API overview
      6m 18s
    5. Offline applications overview
      7m 11s
    6. Video overview
      5m 45s
    7. Encoding video
      8m 23s
    8. Adding video
      5m 58s
  8. 57m 33s
    1. Geolocation API overview
      5m 50s
    2. Web storage API overview
      5m 40s
    3. WebSockets overview
      4m 16s
    4. CSS3 overview
      6m 38s
    5. Enhancing typography with CSS3
      7m 42s
    6. Using @font-face
      7m 11s
    7. Styling HTML5 with CSS3
      10m 23s
    8. Using CSS3 transitions
      9m 53s
  9. 5m 6s
    1. Final thoughts
      3m 49s
    2. Goodbye
      1m 17s

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 ...
HTML5 First Look
4h 28m Beginner Aug 23, 2010

Viewers: in countries Watching now:

In HTML5 First Look, author James Williamson introduces the newest HTML specification, providing a high-level overview of HTML5 in its current state, how it differs from HTML 4, the current level of support in various browsers and mobile devices, and how the specification might evolve in the future. Exercise files accompany the course.

Topics include:
  • Understanding the history of HTML5
  • Using new tags
  • Understanding HTML5 semantics
  • Coding ID and class attributes in HTML5
  • Structuring documents
  • Building forms
  • Exploring HTML5 native APIs
  • Encoding and adding HTML5 video
  • Exploring associated technologies such as CSS3
Subjects:
Developer Web Web Design Web Development
Software:
HTML
Author:
James Williamson

Ensuring cross-browser structure

Our HTML5 layout is now complete. We've tested it in all our browser. We've checked the outline. Everything is good, right? Well, almost. Although most modern browsers handle the new HTML5 semantic elements just fine, and Internet Explorer 9 is supposed to have great HTML5 support, older versions of browsers, most notably Internet Explorer, can have some serious problems rendering your shiny new HTML5 document. So let's take a moment to deal with that before we move on to our next chapter.

So I have the trails.htm file opened and I'll go ahead and open up the main.css file from the _css 04_06 folder as well. So we're working in the 04_06 folder. We need the trails opened and we're going to open up the main.css from the _css folder. We're going to take here of the styles first. There are a few things that we need to do stylistically to make sure that these elements are going to render properly in our browsers. So I'm going to switch over to my CSS file and I'm just going to scroll down a little bit until I get right above the main body selector which is on around line 34 or so.

So the same way that you've probably gotten used to doing a CSS reset for all of your documents. When you start working with HTML5, you're going to probably get used to doing this sort of HTML5 display rule grouping. So basically what we're going to do is we're going to take all the sectioning content and some of the flow content elements and we're going to tell browsers to represent them as display objects. So display them as block model objects basically. Now we're doing this for a couple of reasons. Number one, again Internet Explorer doesn't even recognize these tags.

It doesn't even know what they are, so it certainly doesn't know how it should go about rendering them. That's also a problem with some of our older browsers as well. Plus the HTML5 specification doesn't say how these elements should be displayed, whether they're block or in-line elements. Now, the majority of devices and browsers out there will display them as block level elements, but we call this covering our bases. So what I'm going to do is I'm just going to do html5 display rule. I'm just going to remind myself that that's what this is and I'm going to comment that out.

So I'm just going to add a comment above the selector that I'm about to create. Now, we're going to create a fairly long group selector, so just stay with me on this. So first we're going to do article, aside, canvas, details, figcaption, figure, footer, header, hgroup, menu, nav, section, and then summary.

Go ahead and open up a curly brace, hit Return and the only property we need here is display and we're going display that as a block level element. Then you can go ahead and close your curly brace and the rule's get on there. So there are a lot of elements here. Some of them we've used, some of them we haven't, but these are all elements that should display as block level elements within your browser. Some of these elements, like details and fig caption, aren't even supported yet, even by the most modern browsers. Or they aren't supported at least as of the time of this recording, but we are putting them in there so that we can be forward compatible, so that we get used to doing this rule, if you save it as a snippet, copy and paste it, as browser support matures and you begin using those tags, you don't have to worry about remembering to add them to whatever display rule you've got within your CSS.

Okay, so we're going to go ahead and save that. And now at least we have something telling these browsers and devices that these elements should display as block level elements. But what about a browser like Internet Explorer, who doesn't even understand what those elements are and don't allow for those elements to have existed at all? So Internet Explorer, at least older versions, would really break with our current layout. So, let's take a look at a way we can deal with that. I'm going to switch over and go out to the Google Code web site because I want to show you something that's out there. Okay, so here I'm at code.google.com/p/html5shiv.

So what in the world is this? Well, again Internet Explorer does not recognize those elements that we just set the display property to block on, so our layout would not work in those older versions of Internet Explorer. Well, what this does is that just three lines of code that runs a conditional comment and then if the browser is Internet Explorer less than version 9, it's going to go ahead and run this script which is hosted at Google. All this script really does is create those elements. So it doesn't place them on the page. It just sort of creates them and hangs them up in the ether, so that Internet Explorer goes, "Oh! okay, so those elements do exist.

I will recognize them in the code and I will style them the way that you are telling me style them in your CSS file." So it's a very important line of code. If you don't like linking to a hosted script like this one, you can go ahead and write this yourself. Again, all you're really doing in the JavaScript is creating those elements, so that Internet Explorer recognizes them. This is just a nice, quicker way of doing that. Now if you want to see this JavaScript yourself, you can. It's right here at html5shim. googlecode.com/svn/trunk/html5.js.

This is the minified version of the code. I believe it was written by Remy Sharp. If Remy didn't write this, I apologize to whoever did, but again there are a lot of regular expressions going on here, but the code itself really isn't that difficult. All it's really doing is creating those elements for you. So a faster and easier way to use this perhaps is to just go ahead and copy and paste this into your code and that is what we are going to do. So I'm going to go ahead and highlight these blocks of code right here, so the conditional comment that surrounds it and the script tag. I'm going to copy it and then I'm just going to go back into my HTML editor.

Okay, so I'm back in my trails.htm file. What I want to do is find the closing head tag, which is right here on line seven for me, and I'm just going to create a blank line and paste that code right above the closing head tag. So if I save this, we're now good to go and earlier versions of Internet Explorer will recognize and display those block level elements correctly. So our page is now well and truly finished. We're using HTML5 structural elements and have added new meaning to our content through the use of our semantic markup.

By adding just a few lines of code to our CSS and by adding this quick scripting fix for older versions of Internet Explorer, our HTML5 layout is now a cross-browser compliant as well as semantically rich.

There are currently no FAQs about HTML5 First Look.

 
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 HTML5 First Look.

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

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.