Web Programming Step by Step, 2nd Edition

Chapter 2: HTML Basics

Except where otherwise noted, the contents of this document are Copyright 2012 Marty Stepp, Jessica Miller, and Victoria Kirst. All rights reserved. Any redistribution, reproduction, transmission, or storage of part or all of the contents in any form is prohibited without the author's expressed written permission.

Valid XHTML 1.1 Valid CSS!

2.1: Basic HTML

Hypertext Markup Language (HTML)

Structure of an HTML page

<!DOCTYPE html>
		information about the page

		page contents

Page title: <title>

describes the title of the web page

<title>Chapter 2: HTML Basics</title>

Paragraph: <p>

paragraphs of text (block)

<p>You're not your job.
You're not how much money you have in the bank.
You're not the car you drive.   You're not the contents
of your wallet. You're not your         khakis.  You're
   the all-singing, all-dancing crap of the world.</p>

Headings: <h1>, <h2>, ..., <h6>

headings to separate major areas of the page (block)

<h1>University of Whoville</h1>
<h2>Department of Computer Science</h2>
<h3>Sponsored by Micro$oft</h3>

Horizontal rule: <hr>

a horizontal line to visually separate sections of a page (block)

<p>First paragraph</p>
<hr />
<p>Second paragraph</p>

More about HTML tags

Links: <a>

links, or "anchors", to other pages (inline)

	<a href="http://www.google.com/">Google</a> or our
  <a href="lectures.html">Lecture Notes</a>.

Block and inline elements (explanation)


Images: <img>

inserts a graphical image into the page (inline)

<img src="images/gollum.jpg" alt="Gollum from LOTR" />

More about images

<a href="http://theonering.net/">
	<img src="images/gandalf.jpg" alt="Gandalf from LOTR"
	     title="You shall not pass!" />

Line break: <br>

forces a line break in the middle of a block element (inline)

<p>Teddy said it was a hat, <br /> So I put it on.</p>
<p>Now Daddy's sayin', <br /> Where the
heck's the toilet plunger gone?</p>
  • br should not be used to separate paragraphs or used multiple times in a row to create spacing

Phrase elements : <em>, <strong>

em: emphasized text (usually rendered in italic)
strong: strongly emphasized text (usually rendered in bold)

	HTML is <em>really</em>,
	<strong>REALLY</strong> fun!

Nesting tags

	HTML is <em>really,
	<strong>REALLY</em> lots of</strong> fun!

Comments: <!-- ... -->

comments to document your HTML file or "comment out" text

<!-- My web page, by Suzy Student
     CSE 190 D, Spring 2048       -->
<p>CSE courses are <!-- NOT --> a lot of fun!</p>

2.2: More HTML Elements

Unordered list: <ul>, <li>

ul represents a bulleted list of items (block)
li represents a single item within the list (block)

	<li>No shoes</li>
	<li>No shirt</li>
	<li>No problem!</li>

More about unordered lists

	<li>Family Guy:

Ordered list: <ol>

ol represents a numbered list of items (block)

<p>RIAA business model:</p>
	<li>Sue customers</li>
  • we can make lists with letters or Roman numerals using CSS (later)

Definition list: <dl>, <dt>, <dd>

dl represents a list of definitions of terms (block)
dt represents each term, and dd its definition

	<dt>newbie</dt> <dd>one who does not have mad skills</dd>
	<dt>own</dt> <dd>to soundly defeat
		(e.g. I owned that newbie!)</dd>
	<dt>frag</dt> <dd>a kill in a shooting game</dd>

Quotations: <blockquote>

a lengthy quotation (block)

<p>As Lincoln said in his famous Gettysburg Address:</p>
	<p>Fourscore and seven years ago, our fathers brought forth
		on this continent a new nation, conceived in liberty, and
		dedicated to the proposition that all men are created equal.</p>

Inline quotations: <q>

a short quotation (inline)

<p>Quoth the Raven, <q>Nevermore.</q></p>

We don't use " marks for two reasons:

  1. HTML shouldn't contain literal quotation mark characters; they should be written as &quot;
  2. using <q> allows us to apply CSS styles to quotations (seen later)

HTML Character Entities

a way of representing any Unicode character within a web page

< >&lt; &gt;
é è ñ&eacute; &egrave; &ntilde;
™ ©&trade; &copy;
π δ Δ&pi; &delta; &Delta;
" &&quot; &amp;

HTML-encoding text

	&lt;a href=&quot;http://google.com/search?q=marty&amp;ie=utf-8&quot;&gt;
		Search Google for Marty

Computer code: <code>

a short section of computer code (usually shown in a fixed-width font)

	The <code>ul</code> and <code>ol</code>
	tags make lists.

Preformatted text: <pre>

a large section of pre-formatted text (block)

         Steve Jobs speaks loudly
            reality distortion
           Apple fans bow down

Web page metadata: <meta>

information about your page (for a browser, search engine, etc.)

<meta http-equiv="Content-Type"
         content="text/html; charset=iso-8859-1" />
<meta name="description"
   content="Authors' web site for Building Java Programs." />
<meta name="keywords" content="java, textbook" />

Favorites icon ("favicon")

<link href="filename" type="MIME type" rel="shortcut icon" />
<link href="yahoo.gif" type="image/gif" rel="shortcut icon" />
favicon favicon

HTML tables: <table>, <tr>, <td>

A 2D table of rows and columns of data (block element)

	<tr><td>1,1</td><td>1,2 okay</td></tr>
	<tr><td>2,1 real wide</td><td>2,2</td></tr>
1,11,2 okay
2,1 real wide2,2

Table headers, captions: <th>, <caption>

	<caption>My important data</caption>
	<tr><th>Column 1</th><th>Column 2</th></tr>
	<tr><td>1,1</td><td>1,2 okay</td></tr>
	<tr><td>2,1 real wide</td><td>2,2</td></tr>
My important data
Column 1Column 2
1,11,2 okay
2,1 real wide2,2

2.3: Web Standards

Web Standards

W3C HTML Validator

	<a href="http://validator.w3.org/check/referer">
		<img src="http://webster.cs.washington.edu/w3c-html.png"
		alt="Validate" />

What is HTML 5?

What's new in HTML 5?

What's new, continued

Multimedia is fun

File formats

Image file formats

Raster and vector graphics

bitmap vs. vector

Audio file formats

Video file formats

  • comparisons of formats: 1, 2


Linking to multimedia files

<a href="video.avi">My video</a>

File types and browser plugins

browser plugins

HTML 5 embedding a video

<video src="video.ogv" width="425" height="350"></video>

Embedded objects: <object>

<object data="video.avi" type="video/avi"></object>

Parameters: <param>

<object id="slider1" width="100" height="50">
	<param name="BorderStyle" value="thick" />
	<param name="MousePointer" value="hourglass" />
	<param name="Enabled" value="true" />
	<param name="Min" value="0" />
	<param name="Max" value="10" />

Embedding a YouTube video

<object width="width" height="height"
	<param name="wmode" value="transparent" />
<object width="425" height="350"
	<param name="wmode" value="transparent" />