Note that the images folder contains different size versions of some images. The javascript folder contains the file html5.js, a copy of Remy Sharp's script that cajoles Internet Explorer 6, Internet Explorer 7, and Internet Explorer 8 to apply CSS to the new HTML5 elements.
The structure of an HTML5 page is basically the same as for HTML 4.01 and XHTML 1.0, but some parts of the code are much simpler than before.
You should note two points here: The DOCTYPE declaration and the <meta>
tag that sets the encoding to UTF-8 (Unicode) are both much simpler
than in previous versions of HTML and XHTML. Otherwise, the code is the
same as for HTML 4.01.
Note: The 11.0.3 updater for Dreamweaver CS5 uses a longer version of the <meta>
tag. The longer version is not incorrect, but the version used by Dreamweaver CS5.5 is more succinct.
For backwards compatibility with XHTML 1.0, HTML5 permits the insertion of a closing slash on tags—such as <meta>
, <link>
, and <img>
—that don't have a closing tag. However, Dreamweaver CS5 keeps the code simple by using standard HTML syntax.
Note: To convert existing XHTML pages to HTML5, select File > Convert > HTML5. Dreamweaver changes the DOCTYPE declaration, and removes the closing slashes from single tags.
article, aside, figure, footer, header, nav, section {
display: block;
margin: 0;
padding: 0;
}
This ensures that the HTML5 structural elements are styled as
block-level elements without any margins or padding. In other words,
they will behave exactly the same as <div>
elements.
According to the HTML5 specification: the <header>
element "represents a group of introductory or navigational aids." So, the <header>
will contain the page's main heading, logo, and navigation menu. The <header>
will also contain another HTML5 structural element: <nav>
. Unless you're prepared to type all the tags in Code view, you need to add the elements in a specific order.
Follow the instructions carefully in this section, as it's easy to make a mistake.
<h1>
in the Tag selector to ensure the surrounding tags are selected. Then
right-click the selected text in Design view, and select Wrap Tag from
the context menu.<h1>
heading should now be wrapped in <header>
tags, as shown in Figure 16.<header>
element.<h2>
heading.</h2>
and </header>
tags.<ul>
in the Tag selector to select the
whole unordered list, right-click the selected list in Design view, and
select Wrap Tag from the context menu.nav
in the Wrap tag mini-panel, and press Enter/Return twice to wrap the unordered list in a pair of <nav>
tags.Your HTML code should now look like Figure 17.
<header>
element needs an ID. This is one of the occasions you can use the Property inspector for the HTML5 structural elements.Select <header> in the Tag selector, and type logo in the ID text box. Press Enter or Tab to apply the ID.
<header>
still selected, click the
Insert Div Tag button in the Common category of the Insert panel/bar, or
select Insert > Layout Objects > Div Tag.<header>
in the new <div>
element, and save index.html.Your HTML code should now look like Figure 18.
To save some typing, the main text for the rest of the page is in copy.txt.
<div>
element purely for styling. Click the Insert Div Tag button in the
Insert panel/bar, or select Insert > Layout Objects > Div Tag.<header id="logo">
from this menu, and type maincontent in the ID text box, as shown in Figure 19. Click OK to insert the <div>
element.<article>
tags.<article>
tags, allowing you to add an ID. Type vision in the ID text box in the Property inspector.<article>
element with the first sentence from copy.txt (it begins with "A new
neighborhood"). It's probably easier to do this in Code view, to make
sure you don't accidentally delete the <article>
tags.Type the following code immediately after the <article>
you have just inserted. Although there's a lot of code, code hinting in
Dreamweaver should speed up the process. Also, you can copy and paste
the paragraphs in the final <section>
element from copy.txt.
<section>
<a href="#"><h1>Today's specials</h1></a>
<figure></figure>
</section>
<section>
<a href="#"><h1>Events</h1></a>
<figure></figure>
</section>
<section>
<a href="#"><h1>News</h1></a>
<article>
<p>9/1 Celebrity Guest Chef Night</p>
<p>9/3 New Menu Samplers!</p>
<p>9/4 Chef Citrus Style</p>
<p>9/23 Pork Pork and More Pork</p>
<p>10/1 Celebrity Guest Chef Night</p>
<p>10/3 New Menu Samplers!</p>
<p>10/4 Iron Chef Citrus Style</p>
</article>
</section>
<figure>
tags. If you find it difficult
to get the insertion point in the right place, click to the right of the
heading, and press the down arrow key once.The maincontent <div>
should now look like Figure 20 in Design view.
<time>
tags. Select 9/1 in the first news item, right-click, and select Wrap Tag from the context menu.Type ti to select time from the code hints menu, and press Enter/Return twice to wrap the text in <time>
tags.
<time>
tags, open the Tag Inspector by clicking its tab or selecting Window > Tag Inspector.Make sure the Attributes button is selected, and click in the field alongside datetime
.
The <time>
element requires the date and/or time to be specified in the datetime
attribute in the format recommended by the International Organization
for Standardization (ISO): YYYY-MM-DD HH:MM:SS. In this case, you need
only the date, so type 2011-09-01 in the datetime
field (see Figure 21).
datetime
attribute as necessary.<div#maincontent>
in the Tag Selector to select the whole <div>
element, and press your right arrow key once to position the insertion point outside the closing </div>
tag.<footer>
element. Press Enter/Return to autocomplete the tag. Add the closing angle bracket, and type </ to add the closing </footer>
tag.<footer>
tags, and click the Insert Div Tag button in the Insert panel/bar.In the Insert Div Tag dialog box, select At insertion point from the Insert pop-up menu, type facebookTwitter in the ID text box, and click OK.
<div>
element, and insert the images, icon_facebook.jpg and icon_twitter.jpg inside the <div>
.Copy from copy.txt the two paragraphs containing the address and phone number, and paste them after the <div>
inside the <footer>
element.
The <footer>
code should look like Figure 22.
In Part 2 of this tutorial series, you'll bring the page to life with CSS, including emerging CSS3 features, such as rounded corners, box and text shadows, and transformations.