~~SLIDESHOW~~
We recommend that you view this document in slideshow mode first then go back and read the notes.
====== The Structural Layer ======
We start by revising the most commonly used subset of the eXtensible Markup Language (XHTML).
* [[eg-259:lecture2#origins_and_evolution_of_html|Origins and Evolution of HTML]]
* [[eg-259:lecture2#basic_syntax|Basic Syntax]]
* [[eg-259:lecture2#standard_xhtml_document_structure|Standard HTML Document Structure]]
* [[eg-259:lecture2#day-to-day_markup|Day-to-day Markup]]
* [[eg-259:lecture2#other_elements|Other Elements]]
* [[eg-259:lecture2#more_advanced_markup|More Advanced Markup]]
* [[eg-259:xhtml#syntactic_differences_between_html_xhtml|Syntactic Differences between HTML & XHTML]]
===== Origins and Evolution of HTML =====
* There is a comprehensive History of the evolution of HTML in this Wikipedia article: [[wp>HTML#History|HTML -- History]].
* Mark Pilgrim gives a very readable account of the road to HTML5 in [[http://diveintohtml5.info/past.html|Dive Into HTML5 -- How Did We Get Here?]]
===== Reasons to use the XHTML syntax rather than HTML =====
* HTML has lax syntax rules, leading to sloppy and sometimes ambiguous documents
* HTML processors do not even enforce the few syntax rule that do exist in HTML
* XHTML syntax is stricter, leading to clean and clear documents in a standard form
* The syntactic correctness of XHTML documents can be validated
* HTML5 allows both the less strict conventions of HTML5 and the stricter XHTML syntax.
* To avoid relearning what you already know, we will continue to use the XHTML syntax except where HTML5 syntax is simpler to understand.
===== Basic Syntax =====
* //Elements// are defined by //tags// (markers) which act as containers for //content//: e.g. ''
* The elements '''', ''
----
The language of the document is declared in the ''lang'' attribute. This is useful for browsers who may be visiting your site from another non-english speaking country (particular if that country uses a different character set).
===== A Minimal XHTML Document =====
* A document consists of a //head// and a //body//
* The '''') in the body of the document * W3C HTML Validation Service http://validator.w3.org/file-upload.html ---- //**Notes**// * The content of the ''
* Paragraph Elements
* The '''' tag breaks the current line and inserts a blank line -- the new line gets the beginning of the content of the paragraph
* The browser puts as many words of the paragraph's content as will fit in each line
===== An Example Minimal Valid Document =====
Greetings from your Webmaster!
* I recommend that you download a copy of this document ([[/eg-259/examples/lecture2/example.html|example.html]]) and use it as a template.
[ [[eg-259:css|Jump to CSS]] ]
===== Day-to-day Markup =====
* **//Basic Text Markup//**
* [[eg-259:lecture2#line_breaks|Line Breaks]]
* [[eg-259:lecture2#headings|Headings]]
* [[eg-259:lecture2#quotations|Quotations]]
* [[eg-259:lecture2#font_styles_and_sizes|Font Styles and Sizes]]
* [[eg-259:lecture2#subscripts_and_superscripts|Subscripts and Superscripts]]
* [[eg-259:lecture2#character_entities|Character Entities]]
===== Line Breaks =====
* The effect of the ''
'' tag is the same as that of ''
'', except for the blank line
* An [[/eg-259/examples/lecture2/line-breaks.html|example]] of paragraphs and line breaks:
On the plains of hesitation bleach the
bones of countless millions On the plains of hesitation bleach the
bones of countless millions
----
//**Notes and Details of the Example**//
* Note that ''
who, at the dawn of victory
sat down
to wait, and waiting, died.
'' has no closing tag!
* The example of paragraphs and line breaks: [[/eg-259/examples/lecture2/line-breaks.html|line-breaks.html]]
* Typical display:
who, at the dawn of victory
sat down
to wait, and waiting, died.
On the plains of hesitation
bleach the
bones of countless millions
who, at the dawn of victory
sat down
to wait, and waiting, died.
Headings
Aidan's Airplanes (h1)
The best in used airplanes (h2)
"We've got them by the hangarful" (h3)
We're the guys to see for a good used
airplane (h4)
We offer great prices on great planes
(h5)
No returns, no guarantees, no refunds,
all sales are final (h6)
* //**Typical Display**//
{{eg-259:l2-headings.png|An example of the use of the headings elements}}
===== Quotations =====
* Content of '''' * To set a block of text off from the normal flow and appearance of text * Browsers often indent, and sometimes italicize * Example: [[/eg-259/examples/lecture2/blockquote.html|blockquote.html]] ---- **//Code for the Example//**//**Typical Display**// {{eg-259:l2-blockquote.png|An example of the use of the blockquote element}} ===== Font Styles and Sizes =====
Blockquotes Abraham Lincoln is generally regarded as one of the greatest presidents of the U.S. His most famous speech was delivered in Gettysburg, Pennsylvania, during the Civil War. This speech began with
"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.
Now we are engaged in a great civil war, testing whether that nation or any nation so conceived and so dedicated, can long endure."
Whatever one's opinion of Lincoln, no one can deny the enormous and lasting effect he had on the U.S.
The sleet in Crete
The sleet in Crete
lies completely in the street
lies completely in the street ---- * Can be nested * Boldface -- '''' * Italics -- '''' * Larger -- '''' * Smaller -- '''' * Monospace -- '''' These tags are not affected if they appear in the content of a '''', unless there is a conflict (e.g., italics) ===== Subscripts and Superscripts ===== * Subscripts with ''sub'' * Superscripts with ''sup'' x23x23
---- **//Very Important Note//** * All of this font size and font style stuff can (and should) be done with style sheets, but the tags are not yet deprecated * Block elements **CANNOT** be nested in in-line elements ===== Character Entities ===== Needed to enter certain special characters into a web page ^ Char ^ Entity ^ Meaning ^ | & | & | Ampersand | | < | < | Less than | | > | > | Greater than | | " | " | Double quote | | ' | ' | Single quote | | ¼ | ¼ | One quarter | | ½ | ½ | One half | | ¾ | ¾ | Three quarters | | ? | ° | Degree | |(space) | | Non-breaking space | ---- **//Notes//**: The first four character entities are needed to display the characters that are used by XHTML elements and attributes. For example to display ''Hello World!
'' in a web page we have to enter ''<p class="greeting">Hello World!</p>'' and to display the ''&'' symbol we have to use ''&''. This can make the display of HTML code in a web page quite a challenge! For a full list of the 252 usable character entities see [[http://www.cookwood.com/html/extras/entities.html|1]] and [[http://www.w3.org/TR/html401/sgml/entities.html|2]]. ===== Other Elements ===== * [[eg-259:lecture2#horizontal_rules_and_meta_tags|Horizontal Rules and Meta Tags]] * [[eg-259:lecture2#images|Images]] * [[eg-259:lecture2#hypertext_links|Hypertext Links]] ===== Horizontal Rules and Meta Tags ===== * Horizontal rules * ''
'' draws a line across the display, after a line break * The ''meta'' element (for search engines) * Used to provide additional information about a document, with attributes, not content ===== Images ===== * GIF (Graphic Interchange Format) * JPEG (Joint Photographic Experts Group) * Both use compression, but JPEG compression is better * Portable Network Graphics (PNG) ---- * GIF -- 8-bit color (256 different colors) * JPEG -- 24-bit color (16 million different colors) * Both use compression, but JPEG compression is better * PNG * Relatively new * Should eventually replace both GIF and JPEG ===== Images – Markup =====* Images are inserted into a document with the '''' tag with the ''src'' attribute * The ''alt'' attribute is required by XHTML * The '''' tag has 30 different attributes, including ''width'' and ''height'' * Example Document: [[/eg-259/examples/lecture2/image.html|image.html]] ---- * Purpose of the ''alt'' attribute: - Non-graphical browsers - Browsers with images turned off - Accessibility, e.g. screen readers ----- //**Code for the Example**//
//**Typical Display**// {{eg-259:l2-image.jpg|An example of a document with an image}} ===== Hypertext Links ===== * Hypertext is the essence of the Web! * A link is specified with the ''href'' (hypertext reference) attribute of '''' (the anchor tag) * The content of '''' is the visual link in the document * If the target is a whole document (not the one in which the link appears), the target need not be specified in the target document as being the target * Example: [[/eg-259/examples/lecture2/link.html|link.html]] ---- //**Notes**// Relative addressing of targets is easier to maintain and more portable than absolute addressing //**Code for the Example**//
Images Aidan's Airplanes
The best in used airplanes
"We've got them by the hangarful"
Special of the month
1960 Cessna 210
577 hours since major engine overhaul
1022 hours since prop overhaul
Buy this fine airplane today at a remarkably low price
Call 999-555-1111 today!//**Typical Display**// {{eg-259:l2-link1.jpg|An example of a document with links}} //**Link Target**// The Link Target is [[/eg-259/examples/lecture2/C210data.html|C210data.html]]
A link Aidan's Airplanes
The best in used airplanes
"We've got them by the hangarful"
Special of the month
1960 Cessna 210
Information on the Cessna 210**//Typical Display//** {{eg-259:l2-link_target.jpg|The Target of the Link Example}} ===== Hyperlink Targets ===== * If the target is not at the beginning of the document, the target spot must be marked * Target labels can be defined in many different tags with the ''id'' attribute, as in:
1960 Cessna C210 1960 Cessna 210
577 hours since major engine overhaul
1022 hours since prop overhaul
Buy this fine airplane today at a remarkably low price
Call 999-555-1111 today!* The link to an id must be preceded by a "//pound sign//" (''#''); If the ''id'' is in the same document, this target could be:
Baskets
What about baskets?
* If the target is in a different document, the document reference must be included:Baskets
---- * **Style note**: a link should blend in with the surrounding text, so reading it without taking the link should not be made less pleasant * Links can have images:Info on C210
===== Exercises to Demonstrate Basic XHTML ===== - Create, test and validate an XHTML document for yourself. including your name, address, and e-mail address. You must include your student number, course and level. This document must use several headings and '''', '''', ''
'', '''' and ''
'' tags. - Add pictures of yourself and at least one image (e.g. of your friend, spouse, pet) to the document created in Exercise 1. - Add a second document to the document created for Exercise 1 that describes part of your background, using the word ''background'' as the link content. This document should have a few paragraphs of your personal history. ===== More Advanced Markup ===== * //**Lists**// * [[eg-259:lecture2#unordered_lists|Unordered Lists]] * [[eg-259:lecture2#ordered_lists|Ordered Lists]] * [[eg-259:lecture2#nested_lists|Nested Lists]] * [[eg-259:lecture2#definition_lists|Definition Lists]] * [[eg-259:lecture2#tables|Tables]] * [[eg-259:lecture2#frames|Frames]] ===== Unordered Lists ===== * The list is the content of the '''' tag * List elements are the content of the ''
- '' tag: [[/eg-259/examples/lecture2/unordered.html|unordered.html]] ----
===== Ordered lists ===== * The list is the content of the
Unordered list Some Common Single-Engine Aircraft
- Cessna Skyhawk
- Beechcraft Bonanza
- Piper Cherokee
tag * Each item in the display is preceded by a sequence value: [[/eg-259/examples/lecture2/ordered.html|ordered.html]] ----
===== Nested lists ===== * Any type list can be nested inside any type list * The nested list must be in a list item: [[/eg-259/examples/lecture2/nested_lists.html|nested_lists.html]] ----
Ordered list Cessna 210 Engine Starting Instructions
- Set mixture to rich
- Set propeller to high RPM
- Set ignition switch to "BOTH"
- Set auxiliary fuel pump switch to "LOW PRIME"
- When fuel pressure reaches 2 to 2.5 PSI, push starter button
===== Definition lists ===== * For glossaries, etc. * List is the content of the ''
Nested lists Aircraft Types
- General Aviation (piston-driven engines)
- Single-Engine Aircraft
- Tail wheel
- Tricycle
- Dual-Engine Aircraft
- Wing-mounted engines
- Push-pull fuselage-mounted engines
- Commercial Aviation (jet engines)
- Dual-Engine
- Wing-mounted engines
- Fuselage-mounted engines
- Tri-Engine
- Third engine in vertical stabilizer
- Third engine in fuselage
'' tag * Terms being defined are the content of the ''
- '' tag * The definitions themselves are the content of the ''
- '' tag: [[/eg-259/examples/lecture2/definition.html|definition.html]] ----
===== Exercises to Demonstrate Lists ===== - Create, test and validate an XHTML document to describe an unordered list of a typical supermarket shopping list you write. (If you've never made such a list, use your imagination). - Create, test and validate an XHTML document to describe an unordered list of at least 4 countries. Each element of the list must have a nested list of at least three cities in the country. - Create, test and validate an XHTML document to describe an ordered list of your five favourite movies. - Modify the list of Exercise 6 to add nested, unordered lists of at least two actors and/or actresses in each of your favourite movies. ===== Tables ===== * A table is a matrix of cells, each possibly having content * The cells can include almost any element * Some cells have row or column labels and some have data * A table is specified as the content of a ''
Definition lists Single-Engine Cessna Airplanes
- 152
- Two-place trainer
- 172
- Smaller four-place airplane
- 182
- Larger four-place airplane
- 210
- Six-place airplane - high performance
'' tag * A ''border'' attribute in the ''
'' tag specifies a border between the cells * Tables are given titles with the ''
'' tag, which can immediately follow '' '' ---- //**Notes**// * If border is set to ''"border"'', the browser's default-width border is used * The border attribute can be set to a number, which will be the border width * Without the border attribute, the table will have no lines! ===== Table Rows and Cells ===== * Each row of a table is specified as the content of ''
'' tag * The *row headings* are specified as the content of a '' '' tag * The contents of a *data cell* is specified as the content of a '' '' tag * An example table: [[/eg-259/examples/lecture2/table.html|table.html]] ---- ===== More Table Elements and Attributes ===== For information on column and row spanning, cell alignment, cell spacing and padding see the notes. ----- **//Tables -- colspan//** * A table can have two levels of column labels, e.g.
A simple table
Fruit Juice Drinks Apple Orange Screwdriver Breakfast 0 1 0 Lunch 1 0 0 Dinner 0 0 1 * If so, the ''colspan'' attribute must be set in the ''
Fruit Juice Drinks Orange Apple Screwdriver '' tag to specify that the label must span some number of columns: //**Tables -- rowspan**// * If the rows have labels and there is a spanning column label, the upper left corner must be made larger, using ''rowspan'', e.g.
Fruit Juice Drinks : Apple :* Is created with:
Fruit Juice Drinks Apple Orange Screwdriver * Download the colspan/rowspan example: [[/eg-259/examples/lecture2/cell_span.html|cell_span.html]]. Here is the complete source code:
Fruit Juice Drinks : Apple :===== Table Sections ===== * Header, body, and footer, which are the elements: ''thead'', ''tbody'', and ''tfoot'' * If a document has multiple ''tbody'' elements, they are separated by thicker horizontal lines ===== Exercises to Demonstrate Tables ===== - Create, test and validate an XHTML document to describe a table with the following contents: * The columns of the table must have the headings Pine, Maple, Oak and Fir * The rows must have labels Average Height, Average Diameter, Typical Lifespan, and Leaf Type. * You can make up the data cell values. - Modify, test and validate an XHTML document from Exercise 1 to add a second level column label, Tree, and a second-level row label, Characteristics. - Create, test and validate an XHTML document to describe a table with columns for country, national language, capital city and population. There must be at least five countries in the table. ===== Frames ===== * Frames are rectangular sections of the display window, each of which can display a different document * Because frames are no longer part of HTML5, you cannot validate a document that includes frames * For this reason we shall say no more about them in this module! ===== Syntactic Differences between HTML & XHTML ===== * Case sensitivity * Closing tags * Quoted attribute values * Explicit attribute values * ''id'' and ''name'' attributes ===== The Structural and Presentation Layers ===== * [[eg-259:lecture2|Lecture Home]] * [[eg-259:xhtml|The Structural Layer]] * [[eg-259:css|The Presentation Layer]] * [[eg-259:html5|XHTML 2 and HTML5]] * [[eg-259:css3|CSS 3]]
Rowspan and colspan
Fruit Juice Drinks and Meals Fruit Juice Drinks Apple Orange Screwdriver Breakfast 0 1 0 Lunch 1 0 0 Dinner 0 0 1