Académique Documents
Professionnel Documents
Culture Documents
Patrick Loner
1 Introduction to HTML5
u What is HTML?
u The Current State of HTML
u HTML Resources
u Choosing a Code Editor
u The Relationship of HTML, CSS, and JavaScript
What is HTML?
Hello World!
This is a sample web page that shows
that at the heart of web pages comes
content and style!
It really isn't all that difficult, but it can
be pretty unimpressive
What is HTML?
<!DOCTYPE html>
<html>
<head>
<title>Hello World!</title>
</head>
<body>
<h1>Hello World!</h1>
<p>This is a sample web page that shows that at the heart of web pages comes
content and style!</p>
<p>It really isn't all that difficult, and it can be pretty unimpressive</p>
</body>
</html>
What is HTML?
u HTMLs history
u Started in 1991
HTML Resources
u www.w3.org/TR/html5
u www.whatwg.org/specs/web-apps/current-work/multipage
u www.webplatform.org
u https://developer.Mozilla.org/en-us/docs/web/HTML/Reference
Choosing a Code Editor
u At the heart HTML files are simply text files with an htm or html extension
u While basic text editors can be used its often better to choose a more capable
code editor
u Stay away from word processors for html authoring
u Options
u Notepad
u Notepad++
u TextEdit (Mac)
u Brackets
u Aptana
u Visual Studio Express
u Countless others
Choosing a Code Editor
u This course covers the essentials of HTML but its difficult to do so without
understanding the role of two other technologies
u Cascading Style Sheets (CSS)
u JavaScript
u In properly formatted web design
u HTML structures the page and defines the content
u CSS styles the page and presents the content
u JavaScript controls how the web page behaves
u HTML is the most important of these three elements
Summary
2 The Structure and Components
u The body of the HTML document is the portion that defines all the important
content of your web page
u What you want your visitors to see is all found in the body
u Includes structure to define the content
u Various elements and attributes
u Headings
u Paragraphs
u Sections
u Lists
u Using Headings
u Creating Paragraphs
u Emphasizing Text
u Controlling Line Breaks and Whitespace
u Creating Lists
u Working with Tables
Using Headings
u Cautions
u Do not use headings to decrease font size
u Only use headings when there is semantic meaning, remember that HTML should be
used to define the content not to style it
u Avoid skipping headings
u Best Practices
u Use <header> and <hgroup> elements to further structure the content
Using Headings
.
Creating Paragraphs
u HTML contains four elements that are used to emphasize certain bits of text
as a way of differentiating it from its surrounding content
u Normally means a change in font style for most browsers such as bold or italics
u Screen readers will interpret this and result in a change in voice
u Elements
u <em>
u <i>
u <strong>
u <b>
Emphasizing Text
u Do not use for presentational purposes but only when additional emphasis is
needed
Emphasizing Text
u <p>As we sailed into port, we spied the <i>Black Pearl</i> moored at the dock.</p>
u <p>She really does add that little bit of <i lang="fr">je ne sais quoi</i>.</p>
Emphasizing Text
u The bold element <b> is used to simply instruct the browser to display the
inline text as bold
u The use of this element was frowned upon due to its presentational nature
u HTML5 has redefined <b>
u Identifies content that is stylistically offset from the rest of the text, but no more
important in ter
u <p>In this article, Chris Mills will show you how to combine <b>HTML5</b>,
<b>CSS3</b>, <b>coloured card</b>, and <b>string</b> to create an attractive
mobile for your child's bedroom.</p>ms of its meaning
Controlling Line Breaks and Whitespace
u Lists are powerful tools used to group together similar elements and give site
visitors an easy way to view groups of information
u Lists can be created for just about any type of content
u Lists use at least two components
u A markup element that tells the browser a list is on the way
u A markup element that tells the browser this particular item goes into a list
u Another name for an ordered list would be a numbered list because the
browser will by default assign numeric values to items in the list
u The <ol> element represents a list where the items have been intentionally
ordered and where changing the order of the list would change the meaning
u <ol> represents the name and beginning of a list
u <li>List Item</li>
u <li>List Item</li>
u Another type of list is the definition list that includes various name-value
groups
u Consists of definition terms <dt> followed by definitions of those terms <dd>
u Used for
u Terms and definitions
u Metadata topics and values
u Questions and answers
u Any other group of name-value data
Creating Lists
u Demo
Working with Tables
u Tables got a bad name in previous versions of HTML as they were used to
control the presentation of data not a job of the markup language
u Tables still make sense in many situations
u Lots of numbers
u Numerous fields of text that naturally fall into rows and columns
Working with Tables
u There is a lot of markup that occurs in order to create and work with tables
u <table> - denotes the start and end of a table
u Contains a border attribute which acts as a toggle to turn the border on/off
u Semantics
u The use of HTML markup to enhance and reinforce thee meaning of the pages
content rather than merely concerning the look and feel of the content
u Semantic elements are elements with meaning that help to define the page
content and can be used as opposed to non-semantic elements like <div> and
<span>
Why Structure Matters
u Semantic elements
u <article>
u <aside>
u <section>
u <nav>
u <header>
u <footer>
u Several additional elements exist as well
Controlling Document Outlines
u HTML uses semantic elements like headings and sectioning tags to describe
the outline of the pages contents very similar to a table of contents
u Provides the ability to skim and search your files
u Identifies different types of content and how it relates to other content
Controlling Document Outlines
u Demo
Structuring Elements
u Demo <nav>
Structuring Elements
u Demo <article>
Structuring Elements
u Demo <section>
Structuring Elements
u Demo - <aside>
Structuring Elements
u Demo - <div>
Structuring Elements
u The World Wide Web (WWW) is all about links to other locations making it a
giant playground where you can surf at high speed to different parts of the
world
u Hyperlinks give your web page the ability to interact with other sources
around it in fantastic ways
u Virtually every web page beyond the simplest example will have at least some
form of hyperlink
Working with Links
u Linking to Resources
u Other HTML pages
u Different locations on the same HTML page
u Resources that arent even HTML
u E-mail addresses
u Photos and videos
u Downloadable files
Working with Links
u Absolute Links
u Use a complete URL (uniform resource locator) to connect to a web page or online
resource
u URL components
Protocol Domain name File name
http:// www.abc.com /default.html
Working with Links
u Relative Links
u Use a type of shorthand to specify the URL you are pointing to
u Only used in certain situations like linking within the same page or the same site
u When the browser sees a link like <a href=about.html>About</a> it assumes that
because the domain name is missing it is a relative link
u The browser then uses the domain name to locate the resource
u Additional steps are required if the page is in a different directory
u Relative links have the advantage of functioning even if you happen to move the
web site to another server or domain!
Working with Links
u Demo
u Creating links
u Absolute
u Relative
u Show different directories
Working with Links
u URLs can be fairly picky sometimes even being case sensitive so if your URL
and <a> element arent working try these steps
u Check the capitalization
u Check the extension
u Check the filename
u Check the URL syntax http:// is required for absolute links
u Copy and paste
Working with Links
u There are various ways in which you can customize the links in your web page
u Open linked documents in new windows
u Use the target attribute
u Demo
u Open in new windows
u Custom locations within a web page
u Linking to media
Working with Images
u Images play an important role on the web page and can include
u Logos
u Banners
u Clickable navigation aids
u Content
u When well used they are a key element of page design and when used poorly
they can result in an unreadable, unintelligible page and a poor user
experience
Working with Images
u The first step to working with images is to determine the appropriate file
format and size for your images
u Web-friendly images arent the same as images for other mediums
u Require a smaller size for fast page loading
u Require a cross-platform file type
Working with Images
u Demo
u Resources for more information
u www.w3.org/Graphics
u www.quackit.com/web_graphics/tutorial
u Adding images to the page requires that you know the location of the image
and this works best if you can use relative locations
u You could use absolute source references to images stored elsewhere
u Using relative source references is preferred
u Control
u Speed
u Copyright
u In order to place an image on the page you will use the <img> element
u Known as an empty or singleton element because it only uses a single tag
u Enables you to specify the place on the page where you would like to place the
image
u Uses the src attribute to identify the location of the image
u <p>What a view we have using the Hubble telescope! <img src=hubbleview1.jpg>
u Should use the alt attribute in order to define alternate text to screen readers
u Other attributes
u Title
u Height
u Width
Working with Images
u Demo
Working with Images
u Images can also be used as navigational aids providing an image that is a link
to another resource within the site or on another site
u Nests the <img> element within an <a> element
u <img> element goes in the place that would contain the text to display for the
hyperlink
Working with Images
u Demo creating an image that links and talk about borders and titles to ensure
users know its a link not just an image
Summary
6 Styling Web Pages
u HTML and CSS have a virtually inseparable relationship with one another to
the extent that in order to learn web development you must understand both
languages
u HTML defines the structure
u CSS defines the styling
u The supposed unstyled page doesnt really exist
u Default browser styles
u Custom authored styles
HTML and CSS
u Demo
u Unstyled pages using Firefox vs. Styled pages
HTML and CSS
u Types of Styles
u Inline style adding markup to individual HTML elements
u Internal style sheets sequential markup added to the <style> element in the HTML
document
u External style sheets linking HTML documents to a .css file that contains your
styles
u Style differently based on whether an HTML document is being viewed on a desktop
or a mobile device
HTML and CSS
u Inline styles use the style attribute are applied usually to a single element
within a page
u Essentially passing CSS within the HTML element
u Not very efficient
u Sometimes they are useful such as with HTML based email
Creating Inline Styles
u Font families
u Generic family groups with a similar look like Serif or Monospace
u Serif fonts have small lines at the ends on some characters
u Sans-serif fonts do not have those lines
u Monospace fonts have characters all with the same width
u Font family a specific font family like Times New Roman or Arial
Controlling Typography
Controlling Typography
u While its not required some additional information about the CSS Box Model
can be very helpful when dealing with typography
u The CSS box model is essentially a box that wraps around every HTML element
Controlling Typography
u Demo
Externalizing Styles
u Demo
7 Creating Your Own Web Site