Starting XHTML
CSc 302 Outlines
Using The Server
Linking
SGML, HTML, XHTML.
SGML:
<us>Brackets R</us>
HTML: Simplified.
Most pages are HTML. (Including this one.)
XHTML: New and improved.
Stricter rules.
Easier for clients to parse.
Computers like strict rules.
More control for the designer.
More about this later
Where do you get this whatever-ML stuff?
Special WYSIWYG editors: Front page.
Tag-based editors: HomeSite.
Export: Most any word processes.
Create it in a text editor.
This will be our approach.
More control.
Helps you understand how things work.
XHTML
Balanced tags:
<h1>Major Heading</h1>
Open and closing tags with the same name.
Closing tag has
/
.
Lower case.
Nesting:
<h1>Partly <i>italics</i></h1>
Stand-alone tags:
<hr />
No closing tag; use the slash at the end.
The space is required.
Attributes:
<p align="center">Hi there</p>
Attributes control the interpretation of the tag.
Name and value, value in quotes.
Even if it's a number, XTML requires it be in quotes, always.
Document structure:
<?xml version="1.0" encoding="UTF-8"?>
<!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" xml:lang="en" lang="en">
<head>
<title>XTML Document Structure</title>
</head>
<body>
Document contents.
</body>
</html>
Mostly boiler-plate.
<?xml ... >
: XHTML is a variety of XML.
<!DOCTYPE ...>
: Declares what definition the page follows.
... html ...
: Doc enclosed in
<html>...</html>
...PUBLIC ...EN
: The name of the document.
http:...dtd
: Where to find it.
xmlns
attribute: XML Namespace.
Namespaces are collections of names.
Used to manage tag definitions.
Don't worry about it.
xml:lang
,
lang
: Language in XML and HTML.
<head> ... </head>
: Descriptive and control.
<body> ... </body>
: Contents of the document.
Elements used in
<head>
<title>
: In the stripe.
<meta>
: Describe the document.
Attributes simply say what sort of information is contained in the document. May be used by search engines.
Also used for some random control functions.
Not displayed.
<meta name="keywords" content="rocks, stones, pebbles">
<meta name="generator" content="FredGen 4.3">
<meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<script>
,
<link>
,
<base>
,
<script>
: Later chapters.
Comments:
<!-- Notes to yourself -->
Block Elements. Control the arrangement of large blocks, such as paragraphs.
<p>
,
<p align="center">
, and
left
and
right
.
<h1>
through
<h6>
<div>
: Used with style sheets and alignment.
<div align="center" style="color: blue">
<p>First paragraph.</p>
<p>Another paragraph</p>
</div>
<blockquote>
<pre>
: Preformatted text.
<br />
: Line break.
<hr />
: Horizontal rule. Attributes:
size
,
width
,
align
.
Inline Elements. Generally control what text looks like.
Logical styles. Say what the text is used for.
<abbr>
Abbreviation.
<acronym>
Acronym (but you guessed that already).
<cite>
Citation.
<code>
Sample computer code. Usually set in monospace, often courier
<em>
Emphasis.
<strong>
More emphasis.
<samp>
Sample text. Often works much like
<code>
.
<var>
Variable name. Programming examples.
Physical styles.
<big>
.
<b>
Bold
.
<i>
Italic
..
<u>
Underline
<small>
<strike>
Strikeout
<sub>
Subscript.
<sup>
Superscript.
Lists
.
Form, except for
<dl>
:
<
type
>
. . .
<li>
. . .
</
type
>
<ul>
: Unordered (bullet) list.
Option
type
:
disc
,
square
,
circle
.
<ol>
: Order (numbered) list.
Option
type
:
1
,
I
,
i
,
a
,
A
.
Option
start
: Starting number.
Lists may be nested. Default ordered list symbol may change.
Definition lists.
<dl>
. . .
<dt>
. . .
</dt>
. . .
<dd>
. . .
</dd>
. . .
</dl>
Some differences between XHTML and HTML.
XHTML tags must be lower case; HTML uses any case.
Unclosed XHTML tags are noted:
<hr />
HTML allows some closing tags to be implied; In XHTML, you have to give them.
Attribute values must always be quoted.
Attributes must be
key=“value”
. HTML allows just the
key
in some cases.
Using The Server
Linking