tonero

"hobbies and interests"
other>computing>code

xhtml

Hypertext mark-up language (HTML or XHTML) is the basic coding for a web page. The mark up instructions to the browser on how to display the readable text are contained within the text itself but identified by angle brackets. The instructions divide the text up into elements, each type having its own properties. Rather like word processor styles, some apply to complete blocks of text while others apply to text within a line while a third category define places for other items such as images and videos.

In addition to default characteristics, elements have settable attributes. Now, however, most of these have been replaced by instructions set by styles (cascading stylesheets, CSS) either directly through the style attribute of the element or by a remotely linked style sheet.

Block element tags default characteristics Blank sep line Contains other blocks
<body></body> The outermost container which delineates the page and contains everything visible. Every page has a body except a frameset. No Yes
<div></div> Division, a multipurpose block for text with no default formatting. Can contain any element except body No Yes
<form></form> Delineates a form, which can consist of text, tables, and form elements Yes Yes
<h1></h1>to <h6></h6> Heading; Increasing text sizes are set by browser; h1 is usually has largest text. Yes No
<p></p> Paragraph of text. Yes No
<blockquote></blockquote> A para with both sides indented. Yes Yes
<hr />
forward slash only in XHTML
horizontal line, settable attributes: size (height) in pixels, width in % or pixels, alignment and shading/no shading.
No No
<table></table> table attributes: width, border thickness cellspacing, cellpadding No Table rows only
<td></td> TableCell attributes: width in % or pixels, valign (vertical alignment top middle or bottom), align (horiz alignment left, right, center)), rowspan or colspan (number of cells joined horizontally or vertically) No Yes
<th></th> TableHead holds a header row of cells whose contents are usually centred and boldened No Table cells only
<tr></tr> TableRow holds row of cells No Table cells only
<ul> list items see below</ul> a bulleted list, attribute: type="zzz" where zzz=circle, disk or square Yes ul contains li's only
<ol type="n">list items see below</ol> a numbered list where type can be 1, a, A or I Yes ol contains li's only
<li>list item</li> Must be within ol, ul or li. Left indented. A number or bullet, is set by the enclosing ul or ol, outside the indent. No Yes
<dl>see below</dl> a definition list - contains alternate term (dt) blocks and definition (dt) blocks Yes dl's contain dt's and dd's
<dt>word</dt>
< dd>definition</dd>
dd blocks are indented but dt blocks are not. No dd's yes

Inline elements move with the text as it reflows when browser window width is changed.

Inline element tags Comments and common attributes
<a></a>
hypertext link: takes attribute href="file.htm#anchor" and accesses a new web page(file.htm) or location within a page (#anchor) if included
attribute target="hierarchy" specifies the frame or window the new page should appear
<a ></a> anchor: the attribute name="anchor" defines a named point in document (anchor) for links to point to
<br /> line break: attribute clear="all" is used to prevent text riding up around a floating image
single forward slash only required in XHTML
<b></b> (sometimes <strong>) emboldens text
<i></i> (sometimes <EM>) Italic
<span></span> delineates a general purpose in-line selection of text
<sub></sub> SUBscript.
<sup></sup> SUPerscript.
<!-- comment --> browser ignores anything inside

'Replaced' elements reserve an area on a page in which another file (such as an image) is displayed. Note that images are displayed on the page but are not embedded in it - they must always be provided separately and the location must be specified in the tag using the 'src' attribute and relative addressing.

Replaced element tags Comments and common attributes
<img/> attributes: src="image.gif" width="200" height="120" border="0" hspace="5" align="right" alt="descn for text-only browsers", use title for tool tip
An image place-holder where src points to the image file using relative addressing.
<input type="see below" value etc /> A box or button for user input
<object> </object>
embeds active x, java applet or other object, attributes according to type but including height and width
<select><option>first option
<option>second option</select>
dropdown list for form. See inputs list below
<textarea /> attributes: name="xx" cols="n" rows="n" wrap="virtual"
A multiline text box for inputting data to a form. See inputs list below

The form input elements are defined by their type attribute:

Input elements Tag with attributes notes
Text field <input name="xx" type="text" maxlength="n", size="n" > 1,11
Radio button <input name="xx" type="radio" > 2
Check box <input name="xx" type="checkbox" value="ticked"> 3,12
Reset button <input name="xx" type="reset" > 4,9
Submit button <input name="xx" type="submit" > 5,9
Ordinary button <input name="xx" type="button" value="anything"> 8,9,10
Drop down list <select name="xx" size="2" ><OPTION value="optionvalue">list description </select> 6,11
Text Area <textarea name="xx" cols="n" rows="n" wrap="**" > 7,11
  1. Maxlength refers to field length size to max characters visible
  2. To force a single choice give each radio element in the group the same name, add 'checked' attribute against the one you want as default selection if you want one.
  3. Usually for multiple choice, add 'checked' against any default choices
  4. Resets input values to default
  5. Initiates action defined in form action
  6. Place <option value=optionvalue>list description for each value in list and size=n for number of values visible, usually 1. If used, optionvalue is what goes into the name/value pair, whereas the visitor sees the list description.
  7. Wrap options are off, physical to send as separate lines or virtual to send as one.
  8. Use ordinary buttons to initiate JavaScript
  9. To colour buttons, add a style attribute with color and background-color properties to the button opening tag.
  10. The value of the button appears on the front of the button.
  11. Add a style attribute with color and background-color properties to colour the text boxes.
  12. Any value can be used here but ticked is readily understood.

Frame elements are for use when multiple pages are displayed in one window; this is less popular nowadays.

Frame elements Comments and common attributes
<frame />

attributes: src="any.html" name="panename" marginwidth="2" marginheight="2" scrolling="0"
sets frame name, scrolling requirement and starting file, nests inside frameset

<frameset> </frameset> attributes: cols="50%,50%" rows="*,80" border="0" framespacing="0" frameborder="0"
defines the size and arrangement of a set of frames and type of borders. 0 for no or 1 for yes Spacing in pixels
<noframes></noframes> the text inside this element is displayed when the browser does not display frames

The page begins with a doc type definition which defines the standards which should be used by the browser in interpreting the code. Then there is a head section giving information about the document that is not dispayed in the window. The body element holds the visible content.

Elements within the HEAD of the page:

Tag Function
<head></head> identifies the invisible head section
<title></title> identifies the browser frame title, often used by browsers to identify favourites
<link rel=stylesheet type="text/CSS" href="URL" /> links document to a style sheet, where URL is name & address of style sheet
<style type=text/CSS></style> encloses and identifies styles applicable to the page itself. Protection by comment tag recommended
<script language="JavaScript"></script> encloses and identifies a script which runs when the page opens. Protection by comment tag recommended
<meta name="keywords" content="key1, key2,etc." /> provides a search list for search engines
<meta name="description" content="description of site" /> provides a brief description for search engines
<meta HTTP-EQUIV="Refresh" content="5, URL" /> replaces page by another in the stated number of seconds
<meta HTTP-EQUIV="Expires" content="date & time" /> provides an expiry date for page

Special Character entities

Be aware that not all characters work in all environments

special charactersnumericalnameddisp
left single quote &lsquo;
right single quote &rsquo;
single low-9 quote &sbquo;
left double quote &ldquo;
right double quote &rdquo;
double low-9 quote &bdquo;
dagger &dagger;
double dagger &Dagger;
single left-pointing angle quote &lsaquo;
single right-pointing angle quote &rsaquo;
spade suit &spades;
club suit &clubs;
heart suit &hearts;
diamond suit &diams;
overline, = spacing overscore &oline;
leftward arrow &larr;
upward arrow &uarr;
rightward arrow &rarr;
downward arrow &darr;
trademark sign&#x2122;&trade;
exclamation mark&#33; !
double quotation mark&#34;&quot;"
number sign&#35; #
dollar sign&#36; $
percent sign&#37; %
ampersand&#38;&amp;&
apostrophe&#39; '
left parenthesis&#40; (
right parenthesis&#41; )
asterisk&#42; *
plus sign&#43; +
multiplication sign&#215;&times;×
semicolon&#59; ;
less-than sign&#60;&lt;<
greater-than sign&#62;&gt;>
question mark&#63; ?
at sign&#64; @
left square bracket&#91; [
backslash&#92; \
right square bracket&#93; ]
caret&#94; ^
underscore&#95; _
grave accent&#96; `
left curly brace&#123; {
vertical bar&#124; |
right curly brace&#125; }
tilde&#126; ~
ellipses&#133;&hellip;
en dash&#150;&ndash;
em dash&#151;&mdash;
nonbreaking space&#160;&nbsp; 
inverted exclamation&#161;&iexcl;¡
cent sign&#162;&cent;¢
pound sterling&#163;&pound;£
yen sign&#165;&yen;¥
broken vertical bar&#166;&brvbar; or &brkbar;¦
section sign&#167;&sect;§
umlaut&#168;&uml; or &die;¨
lowercase a, umlaut&#228;&auml;ä
uppercase A, umlaut&#196;&Auml;Ä
lowercase o, umlaut&#246;&ouml;ö
uppercase O, umlaut&#214;&Ouml;Ö
lowercase u, umlaut&#252;&uuml;ü
uppercase U, umlaut&#220;&Uuml;Ü
lowercase sharp s, German&#223;&szlig;ß
copyright&#169;&copy;©
left angle quote&#171;&laquo;«
not sign&#172;&not;¬
registered trademark&#174;&reg;®
macron accent&#175;&macr; or &hibar;¯
degree sign&#176;&deg;°
special charactersnumericalnameddisp
plus or minus&#177;&plusmn;±
superscript two&#178;&sup2;²
superscript three&#179;&sup3;³
acute accent&#180;&acute;´
micro sign&#181;&micro;µ
paragraph sign&#182;&para;
middle dot&#183;&middot;·
cedilla&#184;&cedil;¸
superscript one&#185;&sup1;¹
masculine ordinal&#186;&ordm;º
right angle quote&#187;&raquo;»
one-fourth&#188;&frac14;¼
one-half&#189;&frac12;½
three-quarters&#190;&frac34;¾
inverted question mark&#191;&iquest;¿
uppercase A, grave accent&#192;&Agrave;À
uppercase A, acute accent&#193;&Aacute;Á
uppercase A, circumflex accent&#194;&Acirc;Â
uppercase A, tilde&#195;&Atilde;Ã
uppercase A, ring&#197;&Aring;Å
uppercase AE&#198;&AElig;Æ
uppercase C, cedilla&#199;&Ccedil;Ç
uppercase E, grave accent&#200;&Egrave;È
uppercase E, acute accent&#201;&Eacute;É
uppercase E, circumflex accent&#202;&Ecirc;Ê
uppercase I, circumflex accent&#206;&Icirc;Î
uppercase O, grave accent&#210;&Ograve;Ò
uppercase O, acute accent&#211;&Oacute;Ó
uppercase O, circumflex accent&#212;&Ocirc;Ô
uppercase O, tilde&#213;&Otilde;Õ
uppercase O, umlaut&#214;&Ouml;Ö
uppercase O, slash&#216;&Oslash;Ø
uppercase U, grave accent&#217;&Ugrave;Ù
uppercase U, acute accent&#218;&Uacute;Ú
uppercase U, circumflex accent&#219;&Ucirc;Û
uppercase Y, acute accent&#221;&Yacute;Ý
lowercase a, grave accent&#224;&agrave;à
lowercase a, acute accent&#225;&aacute;á
lowercase a, circumflex accent&#226;&acirc;â
lowercase a, tilde&#227;&atilde;ã
lowercase a, ring&#229;&aring;å
lowercase ae&#230;&aelig;æ
lowercase c, cedilla&#231;&ccedil;ç
lowercase e, grave accent&#232;&egrave;è
lowercase e, acute accent&#233;&eacute;é
lowercase e, circumflex accent&#234;&ecirc;ê
lowercase e, umlaut&#235;&euml;ë
lowercase i, grave accent&#236;&igrave;ì
lowercase i, acute accent&#237;&iacute;í
lowercase i, circumflex accent&#238;&icirc;î
lowercase i, umlaut&#239;&iuml;ï
lowercase eth, Icelandic&#240;&eth;ð
lowercase n, tilde&#241;&ntilde;ñ
lowercase o, grave accent&#242;&ograve;ò
lowercase o, acute accent&#243;&oacute;ó
lowercase o, circumflex accent&#244;&ocirc;ô
lowercase o, tilde&#245;&otilde;õ
division sign&#247;&divide;÷
lowercase o, slash&#248;&oslash;ø
lowercase u, grave accent&#249;&ugrave;ù
lowercase u, acute accent&#250;&uacute;ú
lowercase u, circumflex accent&#251;&ucirc;û
lowercase y, acute accent&#253;&yacute;ý
lowercase y, umlaut&#255;&yuml;ÿ
Greek alphabet   
Alpha, alpha&Alpha;&alpha;Α α
Beta, beta&Beta;&beta;Β β
Gamma&Gamma; &gamma;Γ γ
Omega&Omega;&omega;Ω ω
password dot&#9679;
bullet&#8226;

next

home   •   me   •   walks   •   history   •   photographs   •   other   •   top