Except where otherwise noted, the contents of this presentation are Copyright 2009 Marty Stepp and Jessica Miller.
<
element>
content </
element>
<p>This is a paragraph</p>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> information about the page </head> <body> page contents </body> </html>
.html
<title>
describes the title of the web page
<title>Chapter 2: HTML Basics</title>
head
of the page<p>
(2.1.3)
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>
body
of the page<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>
<hr>
a horizontal line to visually separate sections of a page (block)
<p>First paragraph</p> <hr /> <p>Second paragraph</p>
/>
<
element attribute="
value"
attribute="
value">
content </
element>
<a href="page2.html">Next page</a>
<
element attribute="
value"
attribute="
value" />
<hr />
<img src="bunny.jpg" alt="pic from Easter" />
<a>
(2.1.4)
links, or "anchors", to other pages (inline)
<p> Search <a href="http://www.google.com/">Google</a> now! </p>
href
attribute to specify the destination URLp
or h1
<p><a href="1-internet.html">Lecture Notes 1</a></p> <p><a href="http://www.google.com/" title="Search">Google</a></p>
title
attributeBad:
<p> <a href="1-internet.html">Lecture Notes 1 </p> <p> This text also links to Lecture Notes 1</a> </p>
<img>
inserts a graphical image into the page (inline)
<img src="images/gollum.jpg" alt="Gollum from LOTR" />
src
attribute specifies the image URLalt
attribute describing the image<a href="http://theonering.net/"> <img src="images/gandalf.jpg" alt="Gandalf from LOTR" title="You shall not pass!" /> </a>
a
anchor, the image will become a linktitle
attribute specifies an optional tooltip<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 be immediately closed with />
br
should not be used to separate paragraphs or used multiple times in a row to create spacing<!--
... -->
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>
--
<em>
, <strong>
em
: emphasized text (usually rendered in italic)
strong
: strongly emphasized text (usually rendered in bold)
<p> HTML is <em>really</em>, <strong>REALLY</strong> fun! </p>
<ul>
,
<li>
(2.2.1)
ul
represents a bulleted list of items (block)
li
represents a single item within the list (block)
<ul> <li>No shoes</li> <li>No shirt</li> <li>No problem!</li> </ul>
<ul> <li>Simpsons: <ul> <li>Homer</li> <li>Marge</li> </ul> </li> <li>Family Guy: <ul> <li>Peter</li> <li>Lois</li> </ul> </li> </ul>
<ol>
ol
represents a numbered list of items (block)
<p>RIAA business model:</p> <ol> <li>Sue customers for copying music</li> <li>???</li> <li>Profit!</li> </ol>
<ul> <li>No shoes</li> <li>No shirt</li> <li>No problem!</li> <p>Paragraph after list...</p>
<ul> <li>Simpsons:</li> <ul> <li>Bart</li> <li>Lisa</li> </ul> </li> <li>Family Guy: <ul> <li>Peter</li> <li>Lois</li> </ul> </ul>
li
too early (or not at all) will render correctly in most browsers, but it is incorrect XHTML<dl>
, <dt>
, <dd>
dl
represents a list of definitions of terms (block)
dt
represents each term, and dd
its definition
<dl> <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> </dl>
<blockquote>
(2.2.3)
a lengthy quotation (block)
<p>As Lincoln said in his famous Gettysburg Address:</p> <blockquote> <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> </blockquote>
<q>
a short quotation (inline)
<p>Quoth the Raven, <q>Nevermore.</q></p>
<p>Quoth the Raven, "Nevermore."</p>
We don't use " marks for two reasons:
"
<q>
allows us to apply CSS styles to quotations (seen later)a way of representing any Unicode character within a web page
character(s) | entity |
---|---|
< > | < > |
é è ñ | é è ñ |
™ © | ™ © |
π δ Δ | π δ Δ |
И | И |
" & | " & |
&
on a web page?<p> <a href="http://google.com/search?q=marty&ie=utf-8&aq=t"> Search Google for Marty </a> </p>
<code>
code
: a short section of computer code (usually rendered in a fixed-width font)
<p> The <code>ul</code> and <code>ol</code> tags make lists. </p>
<pre>
a large section of pre-formatted text (block)
<pre> Steve Jobs speaks loudly reality distortion Apple fans bow down </pre>
code
tags?pre
and code
together<pre><code> public static void main(String[] args) { System.out.println("Hello, world!"); } </code></pre>
pre
to preserve whitespace and a code
to describe the semantics of the content<p> <a href="http://validator.w3.org/check/referer"> <img src="http://www.w3.org/Icons/valid-xhtml11" alt="Validate" /> </a> </p>
<meta>
(2.3.3)
information about your page (for a browser, search engine, etc.)
<meta name="description" content="Authors' web site for Building Java Programs." /> <meta name="keywords" content="java, textbook" /> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
head
of your XHTML pagemeta
tags often have both the name
and content
attributes
meta
tags use the http-equiv
attribute instead of name
meta
element to aid browser / web server<meta http-equiv="Content-Type" content="type of document (character encoding)" /> <meta http-equiv="refresh" content="how often to refresh the page (seconds)" /> </head>
Content-Type
gets rid of the W3C "tentatively valid" warning<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
meta
refresh
tag can also redirect from one page to another:<meta http-equiv="refresh" content="5;url=http://www.bjp.com" />
meta
element to describe the page<head> <meta name="author" content="web page's author" /> <meta name="revised" content="web page version and/or last modification date" /> <meta name="generator" content="the software used to create the page" /> </head>
meta
generator
tag (why?)meta
element to aid search engines<head> <meta name="description" content="how you want search engines to display your page" /> <meta name="keywords" content="words to associate with your page (comma-separated)" /> </head>