The HTML
HTML
Displayed below are samples of nearly all the HTML tags out there. I could annotate each tag I list here, but frankly, I haven't the time to make an extremely comprehensive reference sheet of HTML tags and their attributes (properties). Nevertheless, this webpage that I've created for you should be at least a decent and fairly comprehensive resource for all you webmasters out there.
If you'd like a brief history of this section, read this. The HTML Workshop was created at the beginning of 1999 as a place where I randomly placed new HTML I was learning. It was a reference or library to which I could refer whenever I needed some code that I hadn't in my memory yet. There were buttons and text fields and random links and images all over the place. In 2000, I organized the mess into separate text areas (now tables) for others to use. There has been a lot for me to add since then, but the amount of material to put here is rather overwhelming. Hopefully, what I have here so far will suffice.
XHTML
By the way, we were at HTML version 4.01 when I created this section, (and we still are). You may have come across the term "XHTML", which is essentially a stricter version (by XML's rules) of HTML, with differences like stricter rules about...
- closing your tags: <p>your face</p> instead of <p>your face, and <br /> instead of <br>, and <img /> instead of <img>
- using only lowercase tags: <body> instead of <BODY>
- sandwiching your nested tags: <b><u>still your face</u></b> instead of <b><u>still your face</b></u>
- placing quotes around attributes: <p align="right"> instead of <p align=right>
(If you already code your HTML like this, wonderful. I almost do, except for the next part. The quirky part is getting used to closing single tags like <br />. Sorry, I didn't make up the rules.) XHTML is the successor of HTML, and it's currently a parallel standard coexisting with HTML for smoother transitions into the future. There's a little more to the whole XHTML story, but all you need to know is that HTML is probably not going to disappear ever. But for those who fancy XHTML, just know that once you know HTML, you pretty much know XHTML. So get cracking and hacking!
[Last major content updates: 1999-2000; Last introduction text update: 2004;]
- Background Features
- Font Features
- Page Structure
- Image Features
- Links Features
- Form Features
- Spacing and Alignment
- MetaTags
- Other Text Features
- Other Page Display Features
- Externally Linked
- Proprietary Tags
Background Features
The Body Tags
bgcolor="beige" « (Background color of page)
background="image.gif" « (Image as background wallpaper if you want one)
bgproperties="fixed" « (How the background wallpaper is shown...either as fixed in place while scrolling or not)
link="blue" « (Color of a link that hasn't been clicked recently)
vlink="purple" « (Color of a link that has been clicked recently)
alink="white" « (Color of a link while it's still selected after being clicked)
text="black" « (Color of the text on the page unless specified with font tags)
marginheight="0" « (Margins at top and bottom of page)
marginwidth="0" « (Margins at left and right of page)
topmargin="0" « (Margin at top of page)
leftmargin="0" « (Margin at left of page)
rightmargin="0" « (Margin at right of page)
bottommargin="0" « (Margin at bottom of page)
>
Background Music
<noembed><bgsound src="song.mid" loop="infinite"></noembed>
Font Features
The Font Tags
face="times new roman,comic sans ms,helvetica" « If the visitor's computer can't read the first font, it will try to read the second or the ones afterwards.
size="3" « Font size is defined from a scale of 1 to 7, 1 being the largest.
-OR-
size="+0"
color="white"
-OR-
color="#000000"
-OR-
color="000000"
>
</font>
* For the <font style='...... part, refer to my CSS section.
* For more on the differences between point, pixel, em, and % font sizes, see the Sizes section.
Font Scale
|
Font Size 1 Font Size 2 Font Size 3 Font Size 4 Font Size 5 Font Size 6 Font Size 7 |
Font Size -2 Font Size -1 Font Size +0 Font Size +1 Font Size +2 Font Size +3 Font Size +4 |
Formatted Text
<i> italics </i> ← Italic Text (Presentational)
<u> underlined </u> ← Underlined Text
<sup> superscript </sup> ← Superscript Text
<sub> subscript </sub> ← Subscript Text
<strike> strikeout </strike> ← Strikeout Text
<s> strikeout </s> ← Strikeout Text
<tt> teletype </tt> ← Teletype Monospace Text (Presentational)
<big> big <big> ← BIG Text (Presentational)
<small> small <small> ← small Text (Presentational)
<strong> bold </strong> ← Strong Emphasis Text (Structural)
<em> italics </em> ← Emphasis Text (Structural)
Page Structure
Doctype
HTML 4.01 Strict
Allowed: All HTML elements and attributes
Disallowed: Presentational or deprecated elements (like font tags); framesets
<!doctype html public "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>GordeonBleu</title>
</head>
<body>
<p>Gordon Mei
</body>
</html>
HTML 4.01 Loose
Allowed: All HTML elements and attributes, including presentational or deprecated elements (like font tags)
Disallowed: Framesets
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>GordeonBleu</title>
</head>
<body>
<p>Gordon Mei
</body>
</html>
HTML 4.01 Frameset
Allowed: All HTML elements and attributes, including presentational or deprecated elements (like font tags); Framesets
Disallowed: None
<!doctype html public "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>GordeonBleu</title>
</head>
<frameset rows="50,*">
<frame name="navigate" src="pageheaderwithfiftyheight.html">
<frame name="partner" src="pagebodywithflexibleheight.html">
</frameset>
</html>
XHTML 1.0 Strict
Allowed: All HTML elements and attributes
Disallowed: Presentational or deprecated elements (like font tags); framesets
Requirements: Markup must be written in well-formed XML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>GordeonBleu</title>
</head>
<body>
<p>Gordon Mei</p>
</body>
</html>
XHTML 1.0 Transitional
Allowed: All HTML elements and attributes, including presentational or deprecated elements (like font tags)
Disallowed: Framesets
Requirements: Markup must be written in well-formed XML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>GordeonBleu</title>
</head>
<body>
<p>Gordon Mei</p>
</body>
</html>
XHTML 1.0 Frameset
Allowed: All HTML elements and attributes, including presentational or deprecated elements (like font tags); framesets
Disallowed: None
Requirements: Markup must be written in well-formed XML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>GordeonBleu</title>
</head>
<frameset rows="50,*">
<frame name="navigate" src="pageheaderwithfiftyheight.html" />
<frame name="partner" src="pagebodywithflexibleheight.html" />
</frameset>
</html>
XHTML 1.1
Allowed: All HTML elements and attributes
Disallowed: Presentational or deprecated elements (like font tags); framesets
Requirements: Markup must be written in well-formed XML
Additional: Unlike XHTML 1.0 Strict, allows adding modules
<!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>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>GordeonBleu</title>
</head>
<body>
<p>Gordon Mei</p>
</body>
</html>
HTML 5
Notes: Backwards-compatible with XHTML and HTML
<!doctype html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>GordeonBleu</title>
</head>
<body>
<p>Gordon Mei
</body>
</html>
HTML Head, Body, and Title Bar Text
<head>
<title>This text goes in the title bar of your browser window</title>
</head>
<body>
</body>
</html>
Divs and Spans
This has non-semantic, but it allows you to group block elements.
<span>
Neither is this, but it allows you to style or implement interaction on inline elements.
</span>
</div>
Headings
<h2>Heading 2</h2>
<h3>Heading 3</h3>
<h4>Heading 4</h4>
<h5>Heading 5</h5>
<h6>Heading 6</h6>
Image Features
Image Tags
alt="This text will show up in the image placeholder while the image loads."
title="This text will show when you hold the mouse cursor over the image."
height="100"
width="200"
border="2"
align="right"
hspace="1"
vspace="3">
- OR, the XHTML version -
<img src="picture.gif" />
Link Features
Links
title="This text appears in the tooltip box when you hover and pause the mouse cursor over the link."
target="blank">Link</a>
(You can also use style="" and class="". See the CSS section for more info.)
Anchor Links
<a name=whee>
This is the "Whee" section.
"Top of Page" Anchor Link
Link Button
<input type="submit" value="Clickable Button">
</form>
E-mail to:
Tab Index Key
<a tabindex="2" href="something.html">Hit 'tab' key a 2nd time to select this link</a>
<a tabindex="3" href="something.html">Hit 'tab' key a 3rd time to select this link</a>
Base
<base href="http://www.gordeonbleu.com" target="_top" />
</head>
<body>
<a href="somepage.html">This page will inherit gordeonbleu.com/somepage.html as the URL.</a>
</body>
Table Features
Table
<caption>A sample table</caption>
<tr>
<td colspan="2" rowspan="1" valign="center" align="center" bgcolor="pink" width="50" height="20">
I am two columns wide.
</td>
</tr>
<tr>
<td width="50%">
My left foot.
</td>
<td width="50%">
Will always be better than the right one.
</td>
</tr>
</table>
Table Header, Body, and Footer
<thead>
<tr>
<th>Day of the Week</th>
<th>Attendance</th>
</tr>
</thead>
<tbody>
<tr>
<td>Sunday</td>
<td>52</td>
</tr>
<tr>
<td>Monday</td>
<td>55</td>
</tr>
</thead>
<tfoot>
</tfoot>
</table>
Table Scope
<thead>
<tr>
<th></th>
<th scope="col">Day of the Week</th>
<th scope="col">Attendance</th>
</tr>
</thead>
<tbody>
<tr>
<td scope="row">1.)</td>
<td>Sunday</td>
<td>52</td>
</tr>
<tr>
<td scope="row">2.)</td>
<td>Monday</td>
<td>55</td>
</tr>
</tbody>
<tfoot>
</tfoot>
</table>
Table Columns
<thead>
<col width="60" />
<col width="40" />
<col width="30" />
<tr>
<th>Notes</th>
<th>Day of the Week</th>
<th>Attendance</th>
</tr>
</thead>
<tbody>
<tr>
<td>This column</td>
<td>Sunday</td>
<td>52</td>
</tr>
<tr>
<td>will have</td>
<td>Monday</td>
<td>55</td>
</tr>
<tr>
<td>a width of 60</td>
<td>Tuesday</td>
<td>85</td>
</tr>
<tr>
<td>but it should be done with CSS</td>
<td>Wednesday</td>
<td>95</td>
</tr>
</tbody>
<tfoot>
</tfoot>
</table>
Table Column Groups
<colgroup span="2"></colgroup>
<colgroup align="center"></colgroup>
<thead>
<tr>
<th>Column 1 Header</th>
<th>Column 2 Header</th>
<th>Column 3 Header</th>
</tr>
</thead>
<tbody>
<tr>
<td>Column 1 part of colgroup spanning 2 columns</td>
<td>Column 2 part of colgroup spanning 2 columns</td>
<td>Column 3 on its own</td>
</tr>
<tr>
<td>Column 1 part of colgroup spanning 2 columns</td>
<td>Column 2 part of colgroup spanning 2 columns</td>
<td>Column 3 on its own</td>
</tr>
<tr>
<td>Column 1 part of colgroup spanning 2 columns</td>
<td>Column 2 part of colgroup spanning 2 columns</td>
<td>Column 3 on its own</td>
</tr>
</tbody>
<tfoot>
</tfoot>
</table>
Form Features
The Form Tags
</form>
All the checkboxes, textfields, radio buttons, etc. go between these tags.
Drop-down Options Menu (Select)
<optgroup label="American Cities">
<option value="newyork">New York</option>
<option value="sanfrancisco">San Francisco</option>
<option value="seattle">Seattle</option>
<optgroup label="Canadian Cities"> <option value="toronto">Toronto</option>
<option value="vancouver">Vancouver</option>
<option value="Calgary">Calgary</option>
</select>
- OR -
<select disabled="disabled" name="">
<option value="newyork">New York</option>
<option value="sanfrancisco">San Francisco</option>
<option value="seattle">Seattle</option>
</select>
Checkbox
value="This text will show up in the textfield and can be edited by the user."
name="whatever_goes_in_here_shows_up_as_a_label_for_the_form_results_sent_to_you">
Radio Button
value="whatever_goes_in_here_labels_this particular_radio_button"
name="whatever_goes_in_here_shows_up_as_a_label_for_the_form_results_sent_to_you">
Single-Line Text Field
type="text"
size="13"
maxlength="50"
value="This text will show up in the textfield and can be edited by the user."
name="whatever_goes_in_here_shows_up_as_a_label_for_the_form_results_sent_to_you"
class="see_my_css_section_to_read_more_on_customizing_colors_and_fonts_of_textareas">
(Size defines the length of the text field.)
(Maxlength defines the maximum length of text that the user inputs.)
Multi-Line Textbox (Textarea)
rows=5
name="whatever_goes_in_here_shows_up_as_a_label_for_the_form_results_sent_to_you"
class="see_my_css_section_to_read_more_on_customizing_colors_and_fonts_of_textareas">
Text that goes here will appear in the textarea, and users can edit it.
</textarea>
(I put a space inside the tag in the last line to prevent it from being hidden. Remove it before you use this tag.)
Submit Button
class="see_my_css_section_to_read_more_on_customizing_colors_and_fonts_of_textareas">
Reset Button
class="see_my_css_section_to_read_more_on_customizing_colors_and_fonts_of_textareas">
Button
<button type="submit">Button Nose</button>
<button type="reset">Button Nose</button>
Scroll Box
<option>White
<option>Red
<option>Green
<option>Black
<option selected>Bronze
<option>Copper
<option>Coral
<option selected> Olive Green
<option>Cyan
<option>Yellow
</select>
Fieldsets, Legends, and Labels
<fieldset>
<legend>Login Information</legend>
<label for="inputuser">Username:</label>
<input type="text" name="username" id="inputuser" />
<label for="inputpass">Password:</label>
<input type="password" name="password" id="inputpass" />
</fieldset>
</form>
Spacing and Alignment
Next Line (Carriage)
- OR, the XHTML version -
<br />
New Paragraph
-OR-
<p> text </p>
Paragraph Alignment: Left, Center, Right, and Justify
<p align="center">text</p>
<p align="right">text</p>
<p align="justify">text</p>
Blockquote Text
Centered Text
List Items (Bullets)
<li>Bullet 2</li>
<li>Bullet 3</li>
- OR, to be less proper, depending on doctype -
<li>Bullet 1
Unordered Lists
<li> All this text is indented to the right. </li>
</ul>
Ordered Lists
<li>This text will be</li>
<li>Numbered in order</li>
</ol>
Directory Titles
<li>John</li>
<li>Paul</li>
<li>Ringo</li>
<li>George</li>
</dir>
Menu List
<li>Chocolate Shake</li>
<li>Strawberry Shake</li>
<li>Vanilla Shake</li>
<li>Combo Shake</li>
</menu>
Horizontal Rule (Horizontal Line Divider)
- OR, the XHTML version -
<hr />
Definition Lists
<dt>List Item 1 Title</dt>
<dd>This is a description of list item 1.</dd>
</dl>
Abbreviations
Acronym
Address
P. Sherman
Address: 42 Wallaby Way, Sydney, Australia
Phone: (02) 5551 5678
</address>
Citations and Short Quotations
<q lang="en-us">It is impossible for a man to learn what he thinks he already knows.</q>
Deleted and Inserted Text
Definition Term
Code, Keyboard Text, Sample Output, and Variables
Kids, please refrain from typing <kbd>sudo rm -rf *</kbd> in your terminal.
I'm getting the output <samp>-bash: entergodmode: command not found</samp> in my terminal.
Preformatted Text
This text will be displayed by default in a fixed-width (monospace) font (Courier New, Courier, Monaco, Consolas...), and will show any s p a c e s and line breaks.</pre>
Bidirectional Override
Metadata
Description of website when found by search engine (unless search engine ignores metatags)
<meta name="description" content="A page with Gordon's works.">
</head>
Keywords for search engine
<meta name="keywords" content="stories, poetry, Gordon, soup">
</head>
Author for search engine
<meta name="author" content="Gordon Mei">
</head>
HTTP Page Redirect
<meta http-equiv="Refresh" content="0"; url=http://www.ocf.berkeley.edu/~gordeon/">
</head>
Other
How to show HTML tags:
& l t ; = <
& g t ; = >
How to make consecutive HTML spaces (nbsp - nonbreaking spaces):
& n b s p ;
Image Maps
<map id="navigation" name="navigation">
<area shape="rect"#the roasted kind coords="144,52,304,71" href="peanuts.html" title="the roasted kind" />
<area shape="rect"#the 411 coords="144,89,304,107" href="info.html" title="the 411" />
<area shape="rect"#fastens paper nicely coords="144,107,304,125" href="stapler.html" title="fastens paper nicely" />
<area shape="rect"#dirty pop coords="144,125,304,143" href="pop.html" title="dirty pop" />
<area shape="rect"#warm feet coords="144,143,304,161" href="socks.html" title="warm feet" />
<area shape="rect"#pink and hard coords="144,71,304,89" href="eraser.html" title="pink and hard" />
<area shape="circle"#stickies coords="223,292,27" href="postit" title="stickies" />
<area shape="poly"#sugar goodness coords="153,240,175,218,202,207,225,204,241,206,261,213,277,222,290,236,300,250,247,273,232,262,213,262,
200,272,148,246" href="candy.html" title="sugar goodness" />
<area shape="poly"#am i being too forward? coords="248,275,300,252,307,264,311,285,310,309,300,334,287,352,239,316,249,307,252,294,252,282" href="contact.html" title="am i being too forward?" />
<area shape="poly"#step back behind the line please coords="199,273,147,247,138,270,136,296,140,322,150,340,159,351,206,316,195,303,194,284" href="info_sitehistory.html" title="step back behind the line please" />
<area shape="poly"#play those scrolling credits! coords="207,316,160,353,184,371,213,379,240,378,264,370,283,357,286,353,236,315,227,319,219,318" href="credits.html" title="play those scrolling credits!" />
<area shape="default" nohref="nohref" alt="" />
</map>
Embedded Object
<param name="flashandthings" value="flashgordon.swf" />
<embed src="flashgordon.swf" width="640" height="480">
</embed>
</object>
Used to embed Flash, Java applets, ActiveX, and other browser plugin-based media.
Embed Music on Page
Or to have the song play hidden in the background:
<embed src="song.mp3" hidden="true" autostart="true" loop="true"></noembed>
Applets
I am a Java applet.
</applet>
HTML Comments
<!--HTML comments do not show up on the page, but appear in the source code. This makes them useful for extra annotating of your code.-->
<span>I can eat peaches all day.</span>
</div><!--They can appear anywhere in the page.-->
Externally Linked
Javascript (script of type Javascript)
<head>
<script type="text/javascript">
document.write("This is very basic Javascript written inline in the HTML document.")
</script>
<noscript>
This part will run if the user does not have Javascript available.
</noscript>
</head>
Externally Linked Javascript:
<head><script src="jquery.js" type="text/javascript"></script>
</head>
CSS (style)
<head>
<style type="text/css">
@import url("evenmorestyles.css");
body {background-color:#aaccff;}
p {margin:1em 0;}
</style>
</head>
Externally Linked Stylesheet:
<head><link rel="stylesheet" href="htmlshop.css" type="text/css" media="all" />
</head>
Link Tag
<link rel="stylesheet" href="htmlshop.css" type="text/css" media="all" title="htmlshopmain" />
<link rel="alternate stylesheet" href="htmlshoptoo.css" type="text/css" media="all" title="htmlshopalt" />
<link rel="shortcut icon" href="favico.png" type="image/png" />
<link rel="alternate" href="feedmerss.xml" type="application/rss+xml" title="GordeonBleu RSS Feed" />
<link rel="alternate" href="feedmeatom.xml" type="application/atom+xml" title="GordeonBleu RSS Feed" />
</head>
Inline Frame (iframe)
This appears if iframes aren't available to the user.
</iframe>
Frames
<frame name="navigate" src="pageheaderwithfiftyheight.html" scrolling="no" marginheight="1" resize>
<frame name="partner" src="pagebodywithflexibleheight.html" scrolling="yes" marginheight="1" noresize>
</frameset>
<noframes>
If the visitor's browser doesn't support frames, whatever you put here will be shown.
</noframes>
- OR -
<frameset cols="20,*,20">
<frame name="western" src="pageleftnavwithtwentywidth.html" scrolling="no" frameborder="0" resize>
<frame name="central" src="pagecenterwithflexiblewidth.html" scrolling="yes" noresize>
<frame name="eastern" src="pagerightnavwithtwentywidth.html" scrolling="no" marginwidth="1" resize>
</frameset>
<noframes>
If the visitor's browser doesn't support frames, whatever you put here will be shown.
</noframes>
Proprietary
Marquee ("Scrolling Text" Ticker)
<marquee bgcolor="black" width="300" height="14" direction="up" loop="2" behavior="slide" scrollamount="100">
This is a scrolling marquee, and it is not supported by all web browsers (example: older versions of Netscape)m as it is a proprietary tag.
</marquee>
</font>