Except where otherwise noted, the contents of this presentation are © Copyright 2008 Marty Stepp and Jessica Miller and are licensed under the Creative Commons Attribution 2.5 License.
<
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>CSE 190 M: HTML</title>
head
of the page<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>
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.
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> <hr />
First paragraph
Second paragraph
/>
<
element attribute="
value"
attribute="
value">
content </
element>
<a href="page2.html">Next page</a>
<
element attribute="
value"
attribute="
value" />
<img src="bunny.jpg" alt="A bunny" />
<hr />
<a>
links, or "anchors", to other pages (inline)
<p> Search <a href="http://www.google.com/">Google</a> now! </p>
Search Google now!
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>
<p> <a href="http://validator.w3.org/check/referer"> <img src="http://www.w3.org/Icons/valid-xhtml11" alt="validate" /> </a> </p>
<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>
Teddy said it was a hat,
So I put it on.
Now Daddy's sayin',
Where the heck's the toilet plunger gone?
br
should be immediately closed with />
br
should not be used to separate paragraphs or used multiple times in a row to create spacing<img>
inserts a graphical image into the page (inline)
<p> <img src="gollum.jpg" alt="Gollum from LOTR" /> </p>
src
attribute specifies the image URLalt
attribute describing the image<p> <a href="http://theonering.net/"> <img src="gandalf.jpg" alt="Gandalf from LOTR" title="You shall not pass!" /> </a> </p>
a
anchor, the image will become a linktitle
attribute specifies an optional tooltip<!--
... -->
comments to document your HTML file or "comment out" text
<!-- My web page, by Suzy Student CSE 190 D, Spring 2008 --> <p>CSE courses are <!-- NOT --> a lot of fun!</p>
CSE courses are a lot of fun!
<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>
HTML is really, REALLY fun!
<p> <font face="Arial">Welcome to Greasy Joe's. You will <b>never, <i>ever, <u>EVER</u></i></b> beat <font size="+1" color="red">OUR</font> prices!</font> </p>
Welcome to Greasy Joe's. You will never, ever, EVER beat OUR prices!
b
, i
, u
, and font
are discouraged in strict XHTML
.css
file
.css
file: one style sheet can be shared across many pagesselector { property: value; property: value; ... property: value; }
p { font-family: sans-serif; color: red; }
<link>
<head>
...
<link rel="stylesheet" type="text/css" href="filename" />
...
</head>
<link rel="stylesheet" type="text/css" href="style.css" /> <link rel="stylesheet" type="text/css" href="http://www.google.com/uds/css/gsearch.css" />
p { color: red; background-color: yellow; }
This paragraph uses the style above.
color
: color of the element's textbackground-color
: color that will appear behind the elementp { color: red; } h2 { color: rgb(128, 0, 196); } h4 { color: #FF8800; }
This paragraph uses the first style above.
This heading uses the second style above.
This heading uses the third style above.
aqua
, black
, blue
, fuchsia
, gray
, green
, lime
, maroon
, navy
, olive
, purple
, red
, silver
, teal
, white
(white), yellow
p, h1, h2 { color: blue; } h2 { background-color: yellow; }
This paragraph uses the above style.
h2
above)