HTML

Some personal notes

These are personal notes. You are welcome to read them.

Index page

Top-level home page  
Management hints
HTML, javascript
Other
     
More pages here ("technical" pages) Ham radio pages Contents of current page

 


Contents

See this link for a skeleton of a page

 

 


A simple HTML page starts with a few descriptive tags (note that DOCTYPE is deprecated with HTML4.0)
Then comes the header (delimited by <HTML> and </HTML>)
After the header comes the body (delimited by <BODY > and </BODY > )

 

Sample HTML page:

<HTML>

<HEAD>
  <TITLE>HTML Summary - Christopher THULLEN</TITLE>
   <SCRIPT> ... </SCRIPT>
</HEAD>
<BODY >

<CENTER>Text in center of page</CENTER>

<B>Bold</B>   <I>Italics</I>   <U>Underline</U>

<P>
Paragraph (note that the tag "</P>" at the end is not necessary. If <p> encountered, a previous </p> is assumed. )
</P>

<BR> inserts a line break

<!-- This is a comment and does not appear on the displayed page -->

See other useful tags

Codes, accents

<TABLE>

   
   
</TABLE>

   <SCRIPT> ... </SCRIPT>

   <FORM> </FORM>

</BODY>

</HTML>

XHTML

Because of slight differences between HTML and XML, do the following:

To render as xml, put this at the top:
<?xml version="1.0" encoding="UTF-8"?>
However, for IE, if this is on the first line, the DOCTYPE is not recognized. So, it is best to leave this out when rendering in html.

This is the resulting code:
<?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">

HTML

It is best to declare the enconding on the server. However, not everybody has access to the server! So, declare in the document, as close to the top as possible:
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
</head>
Values for the encoding should be in the IANA registry (http://www.iana.org/assignments/character-sets)
This is best option for html documents and xml documents to be rendered as html.

This is the resulting code:

For CSS style sheets, add encoding at the top (1st line):
@charset "utf-8";

 

 


The header <HEAD> ... </HEAD>

Contains any of the following HTML tags in any order:
<base href="url"> Defines the base URL for the HTML document. Absolute URL or relative URL. No closing tag.
href: mandatory. defines the base URL.
target: (_blank, _parent, _self, and _top). Default for target pages. Can be overridden inside tag.
<base target="_top"> always top window
<basefont> set document font deprecated 4.0
<isindex> keywords for searching deprecated 4.0
<link href="url of linked document"> set document link (document toward which the current document has a link)
Attributes:
  • charset: character encoding in target
  • hreflang: language on target
  • rel: type of relationship (appendix, bookmark, etc.). Not fully supported.
  • rev: type of relationship from linked document. Not fully supported. Useful to see which documents point to the current document.
  • target: _blank, _parent, _self, and _top
<link rel="stylesheet" type="text/css" href="styles.css">
<link rev="relation" href="another page in site">
<meta name="name" content="values"> Name/content paired values.
  • Name: can be anything like author, description, keywords, ...
  • http-equiv: "content-type", "expires", "refresh", "set-cookie". Use instead of name attribute. Information to generate HTTP headers.
  • Always define the content-type: <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> (unicode web site)
  • Content: Free text
  • Scheme: Procedure for interpreting meta data. Agree with profile attribute of <head>
  • Core Attributes: dir lang
<meta http-equiv="refresh" content="30"> <Refreshes every 30 seconds >
<script> ... </script> script code
<style type="text/css" or type="text/javascript"> Document-level style sheet rules. Use the style core attribute of each tag for inline style rules.
Core attributes: dir, lang, title
Attribute media="types of media".

Template (remember to remove one of the two lines)

<title>The title</title> Name of document

 

Redirection:
Put the following in .htaccess on root of website:
Redirect 301 /old/old.html http://..../new.html

Do not use for permanent redirection. The "redirect 301" works like a charm so why do this?
<meta http-equiv="refresh" content="10; url=http://the_new_site.com/">

In PHP:
<? header( "HTTP/1.1 301 Moved Permanently" );
header( "Status: 301 Moved Permanently" );
header( "Location: http://..../" );
exit(0); ?>

HTML5

<!DOCTYPE html>  <!-- simplified in HTML5 -->
<html lang="en"> <!-- simplified in HTML5 -->
<head>
   <meta charset="utf-8"> <!-- simplified in HTML5: don't need content=text/html. Always define the character set to prevent security vulnerabilities -->
   <title>the title</title>
   <script src="modernizr.min.js"></script>
   <link rel="stylesheet" href="abc.css" /> <!-- don't need type attribute-->
</head>
<body>
   <a href="http://diveintohtml5.org/detect.html" target="_blank" title="detection in HTML5">    http://diveintohtml5.org/detect.html    </a>
   <a href="http://www.modernizr.com/" target="_blank" title="detection in HTML5">    http://www.modernizr.com/    </a>
</body>
</html>

 


The body <BODY> ... </BODY>

<body bgcolor="color or #FFFFFF" onload="code (for after finished loading)" onunload="code (when unloaded)">
Core Attributes: class dir id lang onclick ondblclick onkeydown onkeypress onkeyup onmousedown onmousemove onmouseout onmouseover onmouseup style title

<frameset cols="50%, 50%" onload="code" onunload="code" >
       <!-- <frameset> tag instead of <body> tag -->
   <noframes> To be viewed properly, this page requires frames. </noframes>
   <frameset rows="33%, 33%, *">
     <frame src="1.html">
     <frame src="2.html">
     <frame src="3.html">
   </frameset>
   <frameset rows="50%, 50%">
     <frame src="4.html">
     <frame src="5.html">
   </frameset>
</frameset> <!-- Instead of </body> tag -->

The frameset tag is used in place of the body tag. (For inline frames, use iframe tag) The only valid tags inside the frameset: frame, frameset, head, and noframe.
Core Attributes: class id style title
Attributes cols/rows: number of column/row frames in a frameset element, indirectly by providing the widths. Quote-enclosed, comma-separated list of values. Percentage, number of pixels, asterisk (*) = left-over space. Cannot use cols with rows.

<frame> ... </frame>
Core Attributes: class id style title
Attributes:

<iframe src="url" height="px" width="px" title="description">This browser does not support inline frames</iframe>
Inline frame into body (not in frameset element). Use to display one HTML page inside another. The text between the tags is displayed when the document cannot show.
Attributes:

 

 

 


Various Tags

 

<H1> Header 1 </H1>


<H2> Header 2 </H2>


<H3> Header 3 </H3>

<H4> Header 4 </H4>

<H5> Header 5 </H5>
<H6> H6 is smallest </H6>

<P ALIGN=LEFT> Againt left margin </P>

<P ALIGN=CENTER> Center </P>

<P ALIGN=RIGHT> Againt right margin </P>

<P ALIGN=JUSTIFY> Justified text (still allowed?) </P>

<A HREF="http:/homer.span.ch/~spaw3435/index.html"> Link </A>
<A NAME="AnchorName"> Specify an anchor in the page </A>

<A HREF="#AnchorName"> (or HREF="document#AnchorName") Click no this to goto to specified anchor (in fact, the line following the anchor) </A>

Remove the underline in the link: modify the style-sheet and put none for A:
<STYLE TYPE="text/css"><!--
   A {text-decoration:none}
   A:link { text-decoration: none; }
--></STYLE>

Remove underline without using style-sheet:
<a href="..." style="text-decoration:none">...</a>
<a href="..." style="text-decoration:underline">...</a>

Alternate text for non-graphic

Some more elements of a style:
<style><!--
a.mlinks
   {font-weight: bold;
    color: #000000;
    text-decoration: none;
    font-size: 10pt;
   }
--></style>

Syntax of URL is : scheme://host.domain/path/file-name scheme for web is http

<HR> Horizontal ruler:


un-numbered list:
<ul type=square|circle|disc>

</ul>

numbered list:
<ol>

  1. <li>list item,<li>
  2. <li>list item<li>
</ol>

Alternating terms:
<dl>

<dt> Term</dt>
<dd> Definition</dd>
<dt> Term</dt>
<dd> Definition</dd>
</DL>

<blockquote> long citations </blockquote>
<cite>shorter citations, remains inline</cite>
<q>quote at beginning and end, remains inline (poorly supported) </q>

<big>big</big>
<small>small</small>
<strong>strong (generally bold)</strong>
<em>emphasis (generally italics)</em>
  <sub>Subscript</sub>
  <sup>Superscript</sup>
<address>

Address (generally italics)
</address>

<del> show editiorial change </del>
<ins> show editiorial change </ins>
Also use style sheets

<dfn> mark the first occurrence of a term </dfn>

<bdo> Change the direction that the text reads, from left to right (the default) over to right to left, or vice versa. Most browsers do not recognize this tag. </bdo>

<pre>
     pre-formatted.  
     Mono-spaced font by default.
     Images not possible. 
     Some tags may not appear inside: big, img, object, small, sub, and sup. 
</pre>

<code>Usually, same appearance for code, kbd, samp, and tt tags </code>
<tt>tt</tt>,   <samp>samp</samp>,   <kbd>kbd</kbd>
<code>
   <var>Use inside <code> or <pre>. Usually italique.</var>
   Note that code does render white spaces and line breaks as does <pre>
</code>


<img>


<map> ... </map> Client-side image map with two or more mouse-sensitive regions. Container for areas.

 

<map name="trymap">
  <area shape="rect" coords="34,44,270,350" title="Computer" alt="Computer" href="imagemap2.html">
  <area shape="rect" coords="290,172,333,250" title="Phone" alt="Phone" href="imagemap2.html">
  <area shape="circle" coords="370,80,50" title="Coffee" alt="Coffee" href="imagemap2.html">
  <area shape="circle" coords="337,300,44" title="Coffee2" alt="Coffee2" href="imagemap2.html">
</map>
<img src="20150101_125138.JPG" alt="tryplace" usemap="#trymap">

 


<span> ... </span>
Inline portion of an HTML document: apply any of the core attributes. Inline because the effects occur in the normal flow of the text and images (without additional linefeeds or carriage returns). Span tags, which can be nested, allow a significant degree of control and manipulation of a localized part of your web page. Use the div tag when you want to apply attributes to a block of code, since this tag causes a line break to occur both before and after the div element.
<span class="CODE"> This line is blue. </span>
<span style="color: blue;"> This line is blue. </span> <-- no css file.


Table <TABLE> ... </TABLE>

See later: <button> <col>, <colgroup>

<TABLE cols=5 border="1" width="100%" cellpadding="5" cellspacing="1">

<CAPTION> Short explanation </CAPTION>
<TR> <TH> Header cell </TH> <TH> Header cell </TH> <TH> Header cell </TH> </TR>
<TR> <TD> One cell </TD> <TD> Another cell </TD> <TD> Third cell </TD> </TR>
<TR> <TD> One cell </TD> <TD> Another cell </TD> <TD> Third cell </TD> </TR>

</TABLE>

Personal tips

 

Template for simple table
<table border=1 cellpadding="3" cellspacing="0">
<tr><th>Header</th></tr>
<tr><td><code>&nbsp;&nbsp;</code></td></tr>
</table>

 

 

<table> ... </table>

<thead> ... </thead>
<tbody> ... </tbody>
<tfoot> ... </tfoot>
New tags that allow scrolling through the body of a large table while both the header and footnote portions remain visible. Use thead, tbody, tfoot in order. No browsers implement.
<td> ... </td>
Unlimited number possible. Sequence: <tr><td> place data here </td></tr> <th> ... </th>
Creates a header cell. Bold font style. The coding sequence is: <tr><th> place header here </th></tr>
The attributes are the same as for <td>

<tr> ... </tr>
Unlimited number of rows. Not inside th, td, or other tr tags.


Scripts <SCRIPT> ... </SCRIPT>

Though server side directives are not scripts, this is a quick note put here to discuss this option. The most used are:
<!--#include file="navfile.html" -->
<!--#include virtual="/menu.html" -->    The path assumes that the base is the root of the site
<!--#echo var="LAST_MODIFIED" -->
<!--#echo var="DATE_LOCAL" -->
<!--#echo var="DATE_GMT" -->
<!--#echo var="DOCUMENT_NAME" -->
Note that the pages must have the extension ".shtml" to tell the server to look at the file before rendering it. Note, however, that not all servers allow server side includes.

Attributes:

<SCRIPT LANGUAGE="JavaScript" src=".\file.js">
<!-- Hide script from early browsers
document.writeln("Hello World!")
// End of hiding script -->
</SCRIPT>
<NOSCRIPT>
This page uses javaScript. If you see this message, then the JavaScript is not enabled
</NOSCRIPT>

JavaScript entities: attribute=&{javascript expression};

JavaScript is case sensitive !!!
// comment text
/* multiple line comment text */

if (cond) statement; else statement;
if (cond) { } else { } // Remember parenthesis

Remember double == in condition !

Object.property
Object.method() // parenthesis for methods !
Object.method(param)
Object.EventHandler="MyCode"

switch (cond) {
case value:
     code;
     break; // Remember break; !
case value:
     code;
     break; // Remember break; !
default:
     code;
}

var var-name=value;

function name(param, param) {statements; return value; } // return stops execution in function
function name() {statements; return value; }

do {statements; break;} while (cond);
while (cond) {statements; break; }
for ([init expr]; [cond]; [incr-expr]) {statements; break; }
for (variable in object) {statements; break; }

with(object) {statements}
// if unqualified name in statements,
// then if property of object then take property else take local or global var

Operators

+ // Concatenation of strings
+ , - , * , /
++ , --
    a=5; x=a++; --> x==5, a==6
    a=5; x=++a; --> x==6, a==6
% // integer remaining 9 % 7 --> 2

== Equal. Note 2 == "2" --> true
!= Not equal. 2 != "2" (!!! test this !!!)
=== strict equal: equal and of same type
!== not equal and/or not of the same type
>
>=
<
<=

&& AND (true expr)  && "cheese" --> "cheese"
       "bread"      && "cheese" --> "cheese"
       (false expr) && whatever --> false

|| OR  (true expr)  || whatever --> true
       "bread"      || whatever --> "bread"
       (false expr) || "cheese" --> "cheese"

! NOT  !(true expr)  --> false
       !"cheese"     --> false
       !(false expr) --> true


?:     cond ? expr-for-true : expr-for-false
,      multiple expressions, evaluate both, return value of second
       for(var i=0, j=0; sadf; i++, j++) document.write(a[i][j] + "<BR>"); --> diagonal values
       for(var i=0, j=0; i<3; i++, j++) document.write(a[i, j] + "<BR>"); --> all elements

delete object, property or element in an array, returning true if the operation is possible

new    first define it by writing a function that specifies its name, properties and methods.

this   Often, the calling object

typeof(a)
typeof a

void(expr) evaluates without returning a value




& AND, | OR, ^ XOR, ~ NOT
Shift:
<< drop <-- 10101010000 <-- 0
>> sign --> SSSS0101010 --> drop
>>> 0   --> 00000101010 --> drop

a op= b <== equivalent ==> a = a op b


Special char

\' single quote
\" double quote
\\ backslash
\b backspace
\f form feed
\n new line
\r carriage return
\t tab

Infinity
NaN
Undefined


Functions

escape(string)
unescape(encodedstring) --> single character Latin-1 equivalent.
eval(codestring): if statements, returns value of the last statement (if there is a value).
                  if expression, value returned.
isFinite(testnumber): True if finite and legal number.
isNan(testvalue): true if not a number and false if a number.
                  isNaN(0/0) --> true
                  isNaN("348") --> false
                  isNaN( 348 ) --> false
number(object) No argument --> 0.
string(object)
parseFloat(string)
    First char not a number --> NaN
    Returns only first number.
parseInt(string, radix)
    Radix (2..36) : base of integer.
    If radix is 0 then guess: 1-9 --> 10, 0 --> octal, 0x --> hex
    First non-white char not a number --> NaN
    Returns only first number (until decimal point)
document.write (a_price.toFixed(2));
    Force display of two decimals. May not work in old browsers.



Arrays

new Array(arrayLength)
new Array(element0, element1, ..., elementN)

create an array literal: specify name and the values of all elements: cars = new Array("Mercedes", "Ford", "Chrysler");
Indexed from 0. cars[1]=="Ford"
create array of 7 without content: A = new Array(7); (but no elements yet). Note: javascript 1.2: A = new Array(7) puts 7 into the only element of A.
Assign something to A[10] and more elements will be created.


String


String.split(value) or String.split("char with double quotes")



Printing

Link on page:

<a href="whatever_print.html"
   target="the_print_window"
   onClick="window.open ('','the_print_window',
            'toolbar=no,directories=no,menubar=yes,
             p;scrollbars=yes,resizable=0,width=700,height=500')"
   class="xyz">
Print Page</a>

Page that is formatted for printing:

<html>
...
<body bgcolor="#FFFFFF" text="#000000">
<table width="680" border="0" cellspacing="3" cellpadding="0">
   <tr>
     <td>
       Content
     </td>
   </tr>
</table>
</body>
</html>
<script language="javascript">
window.print();
</script>

Button to close the page:
<INPUT name=closebutton onclick=window.close() type=button value="Close">

 

JSON

{"name":value - see below, "another name": another value}

The names are always enclosed in DOUBLE quotes

The values can be:

 


Forms <FORM> ... </FORM>

Container for form controls. One form per page recommended. Divide a long form between two or more pages.

<html>
<head>
  <title>Form Examplem</title>
  <script language="JavaScript">
   // Note that onSubmit attribute in the form tag requires a Boolean
  // if true, form is automatically submitted without calling document.formname.submit()
  // if false, form submission is aborted
  function checksubmit()
  {
     if (document.formname.fullname.value == "")
     {
       alert("Please enter your full name")
       document.formname.fullname.focus()
       return false
     }
     if (document.formname.emailaddress.value == "")
     {
       alert("Please enter your email address")
       document.formname.emailaddress.focus()
       return false
     }
     return true
  }
  </script>
</head>
<body onLoad="document.formname.fullname.focus()">
  Please fill out this form.
  <br>
  <form method="post" name="formname" action="page.html"
   onSubmit="return checksubmit()">
  Full Name (required) <input type="text" name="fullname" size="30">
  <br>
  EmailAddress (required) <input type="text" name="emailaddress" size="30">
  <br>
  Phone Number (optional) <input type="text" name="phonenumber" size="15">
  <br>
  <input type="reset" value="Clear">
  <input type="submit" name="submitbtn" value="Submit">
  </form>
</body>
</html>

Simple example for local processing

<FORM METHOD="post" NAME="the_form">
<INPUT TYPE="text" NAME="textbox" VALUE="default text" SIZE=20>
<INPUT TYPE="reset" VALUE="reset" >
<INPUT TYPE="button" VALUE="calc" onClick="local_function(this.form)">
<TEXTAREA NAME="FinalResult" COLS=50 ROWS=6>Default text</TEXTAREA>
<INPUT TYPE="button" VALUE="Highlight All" onClick="javascript:the_form.FinalResult.focus();the_form.FinalResult.select();">
</FORM>


<form action="try1.html" method=get>
<input type=text name="text1" value="this is text 1">
<input type=text name="text2" value="text 2">
<input type=text name="text3" value="1234567890">
<input type=submit>
</form>
Use GET method
How to handle spaces? Escape before?
<button> ... </button>
Button form control. The text can include most HTML tags but cannot display an image map using the map and area tags. No other button tags, fieldset, form, iframe, input, isindex, label, select, or textarea tags.
<input>

<INPUT TYPE=text (default), password, hidden, checkbox, radio, reset, submit, image, button, file
   NAME=
   ALIGN=TOP, MIDDLE, BOTTOM
   CHECKED for RADIO or CHECKBOX
   MAXLENGTH=n (use only if really needed)
   SIZE=n
   SRC=url when TYPE=IMAGE
   VALUE=value
   DISABLED
>


<option> ... </option>
Insert one item in a pull-down form control. By default, when an item is chosen, the value that is added to the contents of the form is the text that appears immediately after the opening option tag. However, you can specify a different value by using the value attribute. Place between the opening and closing select tags. The order of the option tags determines the default order of the list. However, you can use the selected attribute to specify one item always to appear at the top of the list. In general, a pull-down list should be treated as a menu. It is recommended that the text for each item in the list be short, such as one or two words. Ending tag recommended

<select size="2">
<option selected>Angel fish</option>
<option>Cardinal tetra</option>
<option>Cat fish</option>
</select>

 


 

<select> ... </select>
Pull-down list form control.

<select name="SeeAlsoSelect" onChange=ViewCrossReference(this); style="height: 22px; width: 240px">
<option value="html_form.html" selected>form tag</option>
</select>
<a href="javascript:ViewCrossReference(document.MainForm.SeeAlsoSelect)" border=0>
<img src="images/go.gif" border="0" height=22 width="20" value="Go">
</a>

This JavaScript function is placed in the head element.

<script language="JavaScript">
function ViewCrossReference (selSelectObject)
{
if (selSelectObject.options[selSelectObject.selectedIndex].value != "")
{
location.href=selSelectObject.options[selSelectObject.selectedIndex].value
}
}
</script>


<label> ... </label>
Associate text labels with elements inside a form. More than one label to the same element. Poorly implemented by most browsers. <form>
<fieldset>
<legend>Please Enter Your Name</legend>
<label for="firstname">First Name</label><input type="text" id="firstname">
<br>
<label for="lastname">Last Name</label><input type="text" id="lastname">
</fieldset>
</form>


<legend> ... </legend>
Create a caption for the form elements associated with a fieldset group. Poorly implemented by most browsers. <form>
<fieldset>
<legend>Please Enter Your Name</legend>
<label for="firstname">First Name</label><input type="text" id="firstname">
<br>
<label for="lastname">Last Name</label><input type="text" id="lastname">
</fieldset>
</form>

<textarea> ... </textarea>
Multi-line text input control for input of more than one line of data (otherwise: <input type=text>).

 

Some elements to help disabled persons to use a web-site

 


XML

 

XHTML:
elements must be properly nested
documents must be well-formed :
<!DOCTYPE Doctype goes here>
<html xmlns="http://www.w3.org/1999/xhtml">
<head> ... </head><body> ... </body></html>
There are three document types: STRICT, TRANSITIONAL and FRAMESET. See
http://www.w3schools.com/xhtml/xhtml_dtd.asp
Tag names are in lowercase
All XHTML elements must be closed (add extra space before the /)
<p>...</p>
<br />
<hr />
Attribute values are quoted
No minimization: <option selected> should be <option selected="selected">
Replace the name attribute with the id attribute (or keep both for backwards
compatibility)


HTML 4 has events
http://www.w3schools.com/xhtml/xhtml_eventattributes.asp

<?xml version="1.0" > <root_element>...</root_element>
The rest of the XML document must be included in a single root element. All
other elements are child elements of the root element.
<?xml version="1.0" encoding="ISO-8859-1"?>
XML version 1, using the ISO-8859-1 (Latin-1/West European) character set.
Other options are: "UTF-8", "UTF-16". The text editor used to create the
file should have the same encoding!
<a_tag>.. <A_TAG>...</A_TAG>....</a_tag>
Every tag must have a closing tag, and tags must be nested. XML is case
sensitive. Names start with alphabetical characters and can contain numbers
and some punctuation (best not to use "-", ";" and "." though). must no
start with "xml...". Accented characters are fine, but watch compatibility
issues.
<a_tag the_date="2006/06/20">...</a_tag?>
All attributes must be quoted. Use single or double quotes. Note that some
schools of thought say that attributes should not be used. Use child
elements instead. In any case, do NOT use attributes for data. Examples of
what could go in as attributes are unique identifiers of elements and
meta-data.
&amp;lt; and &amp;amp;
"<" and "&amp;" are are illegal. It is best practice to replace "'", "?"
and ">"
<![CDATA[ ... ]]>
This data is not parsed
<!-- comment -->
comment
<?xml-stylesheet type="text/css" href="the_css_sheet.css"?>
Second line in the definition.
<?xml-stylesheet type="text/xsl" href="simple.xsl"?>,
But it is better to use XSL (eXtensible Stylesheet Language). Put reference
in 2nd line of XML document.
<the_prefix:a_tag xmlns:the_prefix="URI (web address)">
This helps resolve name conflicts. Prefix child tabs with <the_prefix:...>
too if needed to prevent name conflicts.

Data Island:

<xml id="the_data_source" src="cd_catalog.xml"></xml>

<table border="1" datasrc="#the_data_source">
<tr>
<td><span datafld="ONE_FIELD"></span></td>
<td><span datafld="ANOTHER_FIELD"></span></td>
</tr>
</table>


The datasrc attribute IN <table> tag binds to XML data island (<xml> tag).
The datasrc attribute corresponds to the id attribute of the XML data
island.
<span> tag refer to corresponding XML elements. <td> tag cannot have datafld
attribute, so use <span> tag.

a document with correct syntax is well formed, a document that is validated
against a DTD is valid.
Check errors with http://www.w3schools.com/dom/dom_validate.asp


Loading into parser:
http://www.w3schools.com/xml/xml_parser.asp


XPath:

7 kinds of nodes:
element, attribute, text, namespace, processing-instruction, comment,
document (root)
Nodes contain other (children) nodes or atomic values. Every node has one
parent.

the_node --> children of the node
/the_node --> children of root
the_node1/the_node2 --> children of the_node2 which is child of the_node1
the_node1//the_node2 --> children of the_node2 which is descendant of
the_node1
//the_node1 --> children of the_node1, wherever it may be
. --> current node
.. --> parent node
@ --> attribute
the_node[1] --> first child of the_node
the_node[last()-1] --> second to last child of the_node
the_node[position()<=4] --> first four children of the_node
the_node[@one_att] --> nodes with attribute "one_att", whatever the value of
the attribute
the_node[@one_att='x'] --> nodes with attribute "one_att" equal to x
the_node[child_node>10] --> selection of child nodes
* --> wildcard
//* --> all elements in the document
node() --> "super wildcard", i.e. all nodes
one_path | another_path --> show both paths
one_node/text() --> select the text of the node
axisname::nodetest[predicate] --> a location step


axis names:
ancestor
ancestor-or-self
attribute
child
descendant
descendant-or-self
following: Everything following the closing tag
following-sibling: The siblings after the current node
preceding
preceding-sibling
namespace: namespace nodes of the current nodes
parent
self

Operators:
| (see above), + - * div(normal division) mod(modulus) = != > >= < <= or and

Stylesheets:

The first line is the <?xml ...> xml declaration tag.
Then follows the root element which is <xsl:stylesheet> or <xsl:transform>
(both are equivalent)
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:transform version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

In the xml document, put a link to the stylesheet (second line):
<?xml-stylesheet type="text/xsl" href="the_stylesheet.xsl"?>

The follows the template(s)
<xsl:template match="/">

Example:
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<h2>Simple example</h2>
</body>
</html>
</xsl:template>
</xsl:stylesheet>

<xsl:value-of select="put xpath here"/> --> returns the value of an element
<xsl:for-each /> --> all elements in a set
<xsl:sort /> --> sort the output
<xsl:if test="expression">...</xsl:if> --> conditional
<xsl:choose>
<xsl:when test="expression">...</xsl:when>
<xsl:otherwise>...</xsl:otherwise>
</xsl:choose>

snippet:
<xsl:for-each select="put xpath here">
<xsl:sort select="on of the elements below" />
<xsl:value-of select="one element" />
<xsl:value-of select="another element" />
<xsl:if test="the_element &amp;lt; 10">
<xsl:value-of select="element shown conditionally" />
</xsl:if>
<xsl:for-each>

<xsl:apply-templates/> --> apply templates at this point
<xsl:apply-templates select="title"/> --> apply templates to specified
elements. Is the select attribute equivalent to the match attribute of the
<xsl:template> tag that should follow.

How to XHTML on browser:
=============

<script type="text/javascript">
// Load XML
var xml = new ActiveXObject("Microsoft.XMLDOM")
xml.async = false
xml.load("cdcatalog.xml")
// Load XSL
var xsl = new ActiveXObject("Microsoft.XMLDOM")
xsl.async = false
xsl.load("cdcatalog.xsl")
// Transform
document.write(xml.transformNode(xsl))
</script>

how to XHTML on the server
===========================

<%
'load the xml file
set xml = Server.CreateObject("Microsoft.XMLDOM")
xml.async = false
xml.load(Server.MapPath("cdcatalog.xml"))

'Load XSL
set xsl = Server.CreateObject("Microsoft.XMLDOM")
xsl.async = false
xsl.load(Server.MapPath("cdcatalog.xsl"))

'Transform file
Response.Write(xml.transformNode(xsl))
%>

 

 

 

 

 


Cascading Style Sheets

 

 

priority for styles:
1. Inline style (inside an HTML element)
2. Internal style sheet (inside the <head> tag)
3. External style sheet
4. Browser default

The CSS syntax is made up of three parts: selector {property: value}
The selector is normally the HTML element/tag. The property is the attribute to be changed. Surround the value with quotes if it has more than one word. Separate property-value pairs with semi-colon. If several selectors take on the same property, separate the selectors with commas.

Summary:

In CSS Applies to tag Comments
tag <tag>  
tag_name.class_selector <tag class="class_selector">  
tag_name.class_selector1
tag_name.class_selector2
<tag class="class_selector1 class_selector2"> Merge several formats
.class_selector <any class="class_selector"> All tags of a particular class
tag[attribute="value"] <tag attribute="value">  
tag#the_id <tag id="the_id">  
#the_id <any id="the_id"> All tags with a particular ID
tag:pseudo-class <a ...> Use in order: a:link, a:visited, a:hover, a:active

Use the class selector for defining several styles for one tag:
p.right_align {text-align: right}
p.center_align {text-align: center}

In the HTML document:
<p class="right_align">
Right-aligned text.
</p>
<p class="center_align">
Center-aligned text.
</p>

Apply two or more classes:
<p class="center_align red_text">
Center-aligned text with red text (assuming that a red_text style is defined).
</p>

A style without a selector applies to all tags:
.center_align {text-align: center}

Apply styles to HTML elements with particular attributes:
input[type="text"] {background-color: red}

Styles for HTML elements with the id selector. The id selector is defined as a #.
The style rule below will match the element that has an id attribute with a value of "green":
#green {color: green}
The style rule below will match the p element that has an id with a value of "para1":
p#para1
{
text-align: center;
color: red
}

/* This is a comment */

Stylesheet defined in sepatate file:
<head>
<link rel="stylesheet" type="text/css"
href="mystyle.css" />
</head>

Style sheet defined in same file:
<head>
<style type="text/css">
<!--
hr {color: sienna}
p {margin-left: 20px}
body {background-image: url("images/back40.gif")}
-->
</style>
</head>

Standalone style:
<p style="color: sienna; margin-left: 20px">
This is a paragraph
</p>

margin: 10px 20px 30px 40px -> top right? bottom left?

Examples http://www.w3schools.com/css/css_background.asp

do not start styles with numbers because this will not work in Mozilla/Firefox ; do not leave spaces between the number and the units: 20px, not 20 px

http://htmlhelp.com/reference/css/ http://www.w3schools.com/CSS/CSS_reference.asp