I think we should use HTML5 rather than XHTML, but stick to the XML syntax (which is an option but not a requirement in HTML5). It is widely supported by modern browsers, although not yet officially a recommendation of the W3C, and the DOCTYPE declaration is much simpler!
I’ve put up some very terse notes HTML and Markup (also accessible from my DRAFT I101 site). Among other things, they point out the essential things we need to know about HTML5 and the XML syntax. I’ve provided links to two validators; validation is important, since web browsers are very non-strict about parsing any kind of HTML (except XHTML).
The way I will teach this in the classroom is to begin with an empty document, fill it with the basic HTML5 structure, view the nearly empty document in a web browser; and then begin iteratively adding elements to the page, checking each addition in the browser, and (at least once, at the end) uploading to both of the validators to check it. I would try to put in both tags of a tag pair (e.g., <p> </p>) and then fill in the content.
(See p. 79) Be able to:
a elements to link to other URLsWe should use HTML5, not XHTML, but use the XML syntax:
Omit the tags <b> and <i>; use <strong> and <em> instead.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8"/>
<title>Insert Title</title>
</head>
<body>
Insert Body
</body>
</html>
An element consists of a pair of tags (such as <body> and </body>) and everything between them.
Recommended editors:
Recommended browser:
Procedure:
file:///C:/Users/userid/Documents/first.html) or double-click on the file to open it (in what?)
/), not backslash (\), to separate directories.file:///C:/Documents%20and%20Settings/userid/first.html"Documents and Settings"?)h1 through h6pem and strong emphasis strongStructure your code with line breaks and indenting.
Whitespace is compressed to a single space, unless it is in a preformatted (pre) element.
Special characters:
< for <> for >& for &It is important to be sure you are writing valid HTML.
Structured elements include lists, “anchor” (a) or link elements, images, and tables.
ol with li list items.ul with li list items.dl with dt terms and dd definitions.Links put the “hyper” in hypertext. Example:
<a href="http://www.iue.edu/registrar/index.php">IU East Registrar</a>
a is the tag name (for “anchor”)href stands for “hyper-reference” and is followed by the URL that the link goes to.
href is an example of an attribute in an HTML tag.IU East Registrar is what is displayed on the web page, that you click on to go to the URL.Parts of the URL:
http:// is the scheme (sometimes called protocol, but it is not always a protocol, e.g., file:// would be just a file on your computer).www.iue.edu is the host name (usually a web server)/registrar/index.php is the path which may represent a file path on the web serverAbsolute URLs contain all of these parts. They completely and unambiguously specify the URL.
Relative URLs omit some of the (leading) parts. Your web browser fills in the missing parts from the context. If the scheme is omitted, it is the same scheme you are coming from. If the host name is omitted, it is the same host name you are coming from. If parts of the file path (leading directories) are omitted, we start from where you are in the file system; .. means go up a level in the directory hierarchy.
Examples of relative URLs:
mypage.iu.edu/~gdweber/page2.html../informatics/business/mis/index.phpFor displaying pictures in your web page. Example:
<img src="whale.jpg" alt="Picture of a whale" width="200" height="50"/>
img tagsrc attribute specifies the location (URL) of the image filealt attribute gives alternate text
width and height attributes are recommended to speed up loading of the web page and avoid jitter (otherwise, the browser can’t figure out how much space to allocate for the images until the image files are downloaded from the web server).XML rules: attribute values should always be quoted, using "..." or '...' quotation marks (not “smart quotes”).
table element
<table border="1">; we will use style to control the table border later. W3C HTML allows border="1" and border="", but WHATWG HTML considers the border attribute obsolete.1tr is a table row enclosing one or more th (table header) or td (table data) elementshtml element) must be entirely contained within one other box; it cannot overlap between two container boxes.The style language is called *Cascading Style Sheets (CSS). The style describes the presentation desired for the document; usually this means appearance, but it could be sound, if the computer reads the document to a visually impaired person.
There are three ways to incorporate CSS into a web page:
Any element (at least any element which is going to be presented) may have a style attribute, which specifies one or more style properties and their values.
Example:
<p style="color: red; font-weight: bold;">He said WHAT?!</p>The head of the web page may contain one or more style elements containing embedded style sheets.
Example:
<head>
...
<style type="text/css">
INSERT STYLE RULES HERE
</style>
</head>
These style elements contain style rules, which we will describe shortly.
The head of the web page may contain one or more link elements that hook up the web page to external style sheets.
Example:
<head>
...
<link rel="stylesheet" type="text/css" href="site-style.css"/>
</head>
These external style sheets contain style rules, like those in style elements.
I usually prefer the third way, an external style sheet, because it is very easy this way for all the pages on a site to share a common style: just link them all to the same style sheet. And if you want to fix up the style, you only have to fix it up in one place.
Now, what are these style rules like? Here’s an example:
p { color: red;
background-color: black;
font-weight: bold;
}
This rule begins with a selector, p, which says what kind of elements it will apply to.
There are many kinds of selectors, but the simplest kind is just the name of an element (here, p for paragraph).
Following the selector is a list of properties (name: value;), enclosed in curly braces ({, }).
Properties of elements of any sort.
color of the text or the background-color
red, navy, olive, etc.#ff0000rgb(255, 0, 0)hsl(120, 50%, 75%)border is described by its color, style, and width (thickness)
thin solid black, medium dashed blue, inset 5px hsl(30, 50%, 50%)thin, medium, thick, or a numerical length with units: in (inches), cm (centimeters), mm (millimeters), pt (points, 1/72 inch), pc (picas, 12 pt), px (pixels)Block display elements are those that get, generally, a rectangular display area. They have a “box.” Most of the elements we have covered are of the block display type. Exceptions are inline display elements (em, strong), and list-item display elements (li, etc.).
Here are some properties you can set for elements that are block displayed.
padding is extra space within the bounding box (think of a “padded cell”: the padding is within the cell to protect the patient)border lines at the bounding boxmargin is extra space outside the bounding box (separating the box from its container)Properties of text content or attributes.
text-align: left | right | center | justifytext-indent: length (can be negative or positive, absolute or percent)font-family: family1, family2, …
"Century Schoolbook L"font-style: normal | italic | obliquefont-size: absolute measure | relative measure | xx-small | x-small | small | medium | large | x-large | xx-large | larger | smallerfont-weight: light | normal | bold | ...text-decoration: underline | overline | ...text-transform: capitalize | uppercase | lowercase | nonefont-variant: small-caps | noneBesides the element-name selectors, there are many other kinds. We will consider just two more in this course: selecting elements by the attributes class and id (identity).
An HTML element can be given a unique ID attribute:
<p id="par1"> ...</p>
<p id="par2"> ...</p>
Style rules can match the ID attribute with selectors such as:
p [id = par1] { ... }
p#par1 { ... }
[id = par2] { ... }
#par2 { ...}
HTML element can be given a class attribute; multiple elements can share the same class value:
<p class="humor">A funny thing happened on the way to the forum ...</p>
<p class="humor">And the next day he said, ...</p>
Style rules can match the class attribute with selectors such as
p [class = humor] { ... }
p#humor { ... }
[class = humor] { ... }
#humor { ...}
Example: TO BE ADDED
Simon Pieters, ed., Differences from HTML4, dated 28 May 2013, retrieved 1 Feb 2014.↩