HTML5 ELearning Kit For Dummies - (HTML5 Elearning Kit For Dummies®)
HTML5 ELearning Kit For Dummies - (HTML5 Elearning Kit For Dummies®)
Listing 1-1: HelloHTML.htm
Copyright © 2012. John Wiley & Sons, Incorporated. All rights reserved.
Hilgraves, R, & Boumphrey, F 2012, HTML5 ELearning Kit for Dummies, John Wiley & Sons, Incorporated, Somerset. Available from: ProQuest Ebook Central. [27 September 2022].
Created from rmit on 2022-09-27 07:59:57.
18
Lesson 1
Figure 1-2 shows what you see when you run and view the preceding code in
the Chrome browser.
Figure 1-2
You can run HTML files from your local folders. Double-clicking an HTML
file displays it in your default browser. To see a web page in another
browser, right-click it and then choose your desired browser from the
context menu that appears.
HTML5 is actually quite relaxed about what’s needed for a legal document. I
urge you, however, to use the somewhat stricter XHTML rules. Doing so will
make your site backward-compatible with older browsers that don’t support
HTML5 and make your code easier to read. The examples you see throughout
Copyright © 2012. John Wiley & Sons, Incorporated. All rights reserved.
Although the DOCTYPE has angle brackets like an HTML tag, it isn’t a tag.
You know this because it begins with an exclamation mark (!).
Hilgraves, R, & Boumphrey, F 2012, HTML5 ELearning Kit for Dummies, John Wiley & Sons, Incorporated, Somerset. Available from: ProQuest Ebook Central. [27 September 2022].
Created from rmit on 2022-09-27 07:59:57.
19
Creating the Framework for an HTML Document
EXTRA INFO
Previous version of HTML and XHTML had much more complicated DTDs. For example, here is one of the pos-
sible DTDs for an XHTML document (there are actually several options):
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Strict//EN” “http://www.
w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd”>
It contains, as well as the type of the document — HTML — a public declaration, and a site where the user
agent can find another document to validate this one. That last sentence was probably a lot of gibberish to you.
It’s all about XML! If you want to find out more (and you don’t need to for this book), see XML For Dummies, 4th
Edition by Lucinda Dykes and Ed Tittel.
One of the beautiful things about HTML5 is that it doesn’t require you to spell out all the gibberish; it just
assumes that if you say that it’s an HTML document, you mean that it’s the most recent version, or HTML5.
Makes sense, right?
Hilgraves, R, & Boumphrey, F 2012, HTML5 ELearning Kit for Dummies, John Wiley & Sons, Incorporated, Somerset. Available from: ProQuest Ebook Central. [27 September 2022].
Created from rmit on 2022-09-27 07:59:57.
20
Lesson 1
<head>
<title>Hello World Example</title>
<meta http-equiv=”content-type” content=”text/
html;charset=utf-8” />
</head>
The important tags are highlighted so you can easily see them.
In the browser, Hello World Example appears in the browser’s title bar.
The link element is used for linking to other files. The most important use is
for linking to a file containing a CSS code, which contains the formatting and
positioning instructions for your web page content. You find details about
creating CSS in Lessons 4 and 5, and Lesson 5 has specifics about linking a
CSS file to an HTML file.
For now, notice that the <link> element contains three attributes, which are
empty (don’t contain any values yet) in HelloHTML.htm:
✓ rel tells the user agent that it’s dealing with a link to a style sheet.
✓ type gives the media type of the style sheet.
✓ href tells the agent where to find the style sheet file.
Hilgraves, R, & Boumphrey, F 2012, HTML5 ELearning Kit for Dummies, John Wiley & Sons, Incorporated, Somerset. Available from: ProQuest Ebook Central. [27 September 2022].
Created from rmit on 2022-09-27 07:59:57.
21
Creating the Framework for an HTML Document
EUC-JP or SHIFT_JS. One of the most commonly you’ll be manually moving the
used character set values is UTF-8. page around a lot. Otherwise, this
element is rarely used. Modern
<meta http-equiv=”content- site maintenance software auto-
type” content=”text/ matically changes relative href
html;charset=utf-8” /> and src values.
Hilgraves, R, & Boumphrey, F 2012, HTML5 ELearning Kit for Dummies, John Wiley & Sons, Incorporated, Somerset. Available from: ProQuest Ebook Central. [27 September 2022].
Created from rmit on 2022-09-27 07:59:57.
22
Lesson 1
about filling the <body> element with content, but you can see examples of
elements within the body in the example HelloHTML.htm file:
<body>
<h1 id=’h1’>Hello HTML!</h1>
<p id=’p1’><strong>HTML</strong> was invented by
<em>Tim Berners-Lee</em> in 1993. All markup
was considered <b>semantic.</b></p>
</body>
Before you start building web pages in HTML, knowing the following quirks
about how HTML elements work will help you code pages that look the way
you intend them to:
Hilgraves, R, & Boumphrey, F 2012, HTML5 ELearning Kit for Dummies, John Wiley & Sons, Incorporated, Somerset. Available from: ProQuest Ebook Central. [27 September 2022].
Created from rmit on 2022-09-27 07:59:57.