CH01 - HTML5
CH01 - HTML5
• Create web pages with HTML
Principles of Web Design
Principles of Web Design • Add style with CSS
Add style with CSS
6th Edition • Describe the history of HTML
• Work with HTML5
• Use good coding practices
Use good coding practices
Chapter 1 –
p HTML5
2
3 4
HTML Syntax
HTML Syntax
• Web page code is a mixture of the text the user
sees in the browser surrounded by a variety of
markup elements
• An element
An element is a pair of HTML tags containing
is a pair of HTML tags containing
content
• An HTML tag includes an opening bracket (<), an
A HTML t i l d i b k t (<)
element name such as h1, and a closing bracket
• The end tag has a slash ( / ) preceding the
element.
5 6
HTML Syntax
HTML Syntax HTML Syntax
HTML Syntax
• Some HTML elements contain only a single
g
tag. These are known as void elements
• Void elements insert something onto the
page such as a new line using the <br>
page, such as a new line using the <br>
element
7 8
HTML Syntax
HTML Syntax Structure of a Basic Web Page
Structure of a Basic Web Page
• Some HTML elements support attributes that • The HTML file contains content text and HTML
y p
let you provide more information about an markupp
element • The HTML markup does not appear in the
• Here is an attribute (shown in bold) added to
Here is an attribute (shown in bold) added to browser
an <h1> element: • The browser interprets the code and displays
<h1 id="maintitle">Main Title of the the results
Document</h1>
9 10
13 14
17 18
CSS Syntax
CSS Syntax
• Style rules express style characteristics for an
HTML element
• For example, the following style rule sets all
<p> elements to blue text:
<p> elements to blue text:
P {color: blue;}
• Style rules contain a selector and a
declaration
• You will learn more about CSS in Chapter 4
19 20
Organizing Information with Hypertext
Organizing Information with Hypertext
• The World Wide Web links information on
p g yp
related topics using hypertext Understanding the History of HTML
• You determine which terms to create as
hypertext links and where users end up when
hypertext links and where users end up when
they click a link
• The different types of linked content and
media continually evolve
media continually evolve
21 22
23 24
The History of HTML
The History of HTML A Need for Standards
A Need for Standards
• HTML is an application of the Standard • The World Wide Web Consortium (W3C) was
p g g (
Generalized Markup Language (SGML), a ) founded in 1994 MIT
standard system for specifying document • The World Wide Web Consortium sets
structure
structure standards for HTML and other markup
standards for HTML and other markup
• Berners‐Lee joined the ideas of the user languages
interface (browser), a markup language
f (b ) k l • Jointly developed standards, rather than ones
(HTML), and a communications protocol dictated by one vendor, benefit everyone
dictated by one vendor, benefit everyone
(http:) that allowed hypertext linking
25 26
27 28
XML Syntax Rules
XML Syntax Rules Sample XML
Sample XML
• Documents must be well‐formed <poem>
< >
<title>An Ode to the Web</title>
• All tags must nest properly and not overlap
All tags must nest properly and not overlap < t
<stanza>
>
• Use all lowercase for element names <line>So many web sites</line>
<li >S littl
<line>So little ti
time</line>
</li >
• Always use closing tags
<line>And all I want to do</line>
• Empty elements are signified by a closing slash
Empty elements are signified by a closing slash <li >I critique
<line>Is iti th
their
i
• Attribute values must be contained in design!</line>
</stanza>
quotation marks
</poem>
29 30
33 34
37 38
39 40
Choosing the Correct Syntax
Choosing the Correct Syntax Choosing the Correct Doctype
Choosing the Correct Doctype
• It is a best practice to code using syntax that • Always use a doctype statement
y
follows the stricter syntax rules, which are • Using a doctype forces the browser to display
Using a doctype forces the browser to display
based on XML rules in standards mode
• The code you create for web content can have
The code you create for web content can have • The standard doctype statement for HTML5:
Th d dd f HTML5
multiple purposes and potentially be used in a <!DOCTYPE html>
variety of display and application
f l l
environments
41 42
45 46
Attributes in HTML5
Attributes in HTML5 Obsolete Elements in HTML5
Obsolete Elements in HTML5
• Elements can contain attributes that set • Many elements have been removed in HTML5,
p p
properties y gp
mostly involving presentation effects
• Earlier versions of HTML had more attributes • Framesets are no longer available
• HTML5 has less attributes because of CSS
HTML5 h l ib b f CSS
• Global attributes can be applied to any
pp y
element
47 48
Using HTML5 Elements for Page
Structure
• Most web pages contain common characteristics:
– Header
– Navigation
– Articles
– Figures
– Footers
– Sidebars
• Until recently, most web pages were marked up
with <div> elements and id or class names
49 50
Using HTML5 Elements for Page Using HTML5 Elements for Page
Structure Structure
• The HTML5 elements for page layout include:
h l f l i l d • HTML5 offers a new set of elements for
– <header> Contains the page header content g
describing document structure
– <nav> Contains the navigation elements for the page
– <article> Contains the primary page content
• HTML5 replaces the use of <div> with named
– <section> Defines sections or groupings of page elements to structure the page
elements to structure the page
content • The <article> element can be used instead of
– <aside> Contains additional content such as a quote
d dd l h the <div> element, for example:
or sidebar
– <figure> Contains images for the article content
<fig re> Contains images for the article content <article>This is the main content of
– <footer> Contains page footer content the web page</article>
51 52
Interactive Capabilities in HTML5
Interactive Capabilities in HTML5
• Audio and video
• Drawing canvas
Drawing canvas
• Background application processing
• Local data storage
53 54
55 56
Stick to the Standards
Stick to the Standards Use Semantic Markup
Use Semantic Markup
• Stick to the W3C standards • Semantic markup identifies the intended use
i k id ifi h i d d
• Separate content from presentation
Separate content from presentation of document sections
• Accurately describes each piece of content
• Plan to be accessible to different devices
• Until recently, this logical use of the HTML
Until recently this logical use of the HTML
• Standardized design is more accessible elements was largely ignored
• Document elements match the meaning and
Document elements match the meaning and
usage of the document sections: <p> for
paragraph, <h1> for top‐level heading, and so
h <h1> f t l l h di d
on
57 58
59 60
Summary
• Make sure to check for support of new HTML5
elements
• Use Cascading Style Sheets
• Code to the stricter HTML5 standard
C d h i HTML5 d d
• Use good coding practices
g gp
• Use semantic markup
61