Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
notes:html_cheat_sheet [2008/08/14 04:10]
smthng
notes:html_cheat_sheet [2008/08/15 02:59] (current)
smthng
Line 11: Line 11:
   * A simple HTML web page   * A simple HTML web page
 <code html> <code html>
 +<!DOCTYPE ...>
 <html> <html>
-<head> <title> Title of page </title> </head> +  <head> <title> Title of page </title> </head> 
-<body background=url> This is my first webpage. </body>+  <body background=url> This is my first webpage. </body>
 </html> </html>
 </code> </code>
 +  * HTML 4 comes in three versions :
 +    * Strict which contains no deprecated elements or frames <code html>
 +<!DOCTYPE HTML PUBLIC
 +"-//W3C//DTD HTML 4.01//EN"
 +"http://www.w3.org/TR/html4/strict.dtd"></code>
 +    * Transitional which includes deprecated elements <code html> <!DOCTYPE HTML PUBLIC
 +"-//W3C//DTD HTML 4.01 Transitional//EN"
 +"http://www.w3.org/TR/html4/loose.dtd"></code>
 +    * Frameset which includes deprecated elements and frames <code html><!DOCTYPE HTML PUBLIC
 +"-//W3C//DTD HTML 4.01 Frameset//EN"
 +"http://www.w3.org/TR/html4/frameset.dtd"></code>
  
 ==== HTML Components ==== ==== HTML Components ====
   * HTML documents are text files consisting of HTML elements.   * HTML documents are text files consisting of HTML elements.
-  * HTML elements are defined using HTML tags.+  * HTML elements are defined using HTML tags. [[http://www.w3schools.com/tags/ref_byfunc.asp | HTML Tag Reference]].
   * HTML tags contain the element name surrounded by angle brackets (** < > **).   * HTML tags contain the element name surrounded by angle brackets (** < > **).
   * HTML tags normally come in pairs - the **start tag**(<p>) and the **end tag** (</p>).   * HTML tags normally come in pairs - the **start tag**(<p>) and the **end tag** (</p>).
Line 26: Line 38:
   * Attribute values should always be either single or double-quoted.   * Attribute values should always be either single or double-quoted.
   * Element and attribute names are not sensitive but lowercase names are recommended and required in XHTML.   * Element and attribute names are not sensitive but lowercase names are recommended and required in XHTML.
 +  * [[http://www.w3schools.com/tags/ref_standardattributes.asp | Standard attributes]] valid for most elements include: class, id, title, style, lang.
  
 ==== Formatting Tags ==== ==== Formatting Tags ====
Line 52: Line 65:
   * <code html>   * <code html>
      <table border="1">      <table border="1">
 +     <caption>My Table</caption>
      <tr><th>header 1</th> <th>header 2</th></tr>      <tr><th>header 1</th> <th>header 2</th></tr>
      <tr><td>row 1-cell 1</td> <td>row 1-cell 2</td></tr>      <tr><td>row 1-cell 1</td> <td>row 1-cell 2</td></tr>
      </table> </code>      </table> </code>
   * A table with border 0 can be used to format the layout of a page.   * A table with border 0 can be used to format the layout of a page.
 +  * A table can also be in the form:  <thead> <tfoot> <tbody> , but all three must be specified and contain at least one row.
 +  * To set attributes of columns in a table, a colgroup with column entries can be used e.g. <code html>
 +<table border="1">
 +<colgroup span="2">
 +<col width="20"></col>
 +<col width="50"></col>
 +</colgroup> ... </table>
 +</code>
  
 ==== Forms ==== ==== Forms ====
Line 107: Line 129:
  
 ==== Character Entities ==== ==== Character Entities ====
-  * A character entity represents a single character. [[http://www.w3schools.com/tags/ref_entities.asp | All named entities]].+  * A character entity represents a single character. [[http://www.w3schools.com/tags/ref_entities.asp | Character entities]] [[http://www.w3schools.com/tags/ref_symbols.asp | Symbol Entities]].
   * It consists of an ampersand (&), an entity name or a # and an entity number, and finally a semicolon (;) (e.g. &#60;).   * It consists of an ampersand (&), an entity name or a # and an entity number, and finally a semicolon (;) (e.g. &#60;).
   * Common character entities include: &gt; , &lt; , &nbsp; (space), &quot; , &apos; .   * Common character entities include: &gt; , &lt; , &nbsp; (space), &quot; , &apos; .
   * Other common symbols include: cent ¢, pound £, yen ¥, euro €, copy ©, times ×, div ÷, reg ®, sect §   * Other common symbols include: cent ¢, pound £, yen ¥, euro €, copy ©, times ×, div ÷, reg ®, sect §
 +  * Non-standard letters and other characters can be displayed url-encoded using [[http://www.w3schools.com/html/html_urlencode.asp | hexadecimal format]] e.g. %20.
  
-==== Advanced HTML ==== +==== HTML Head ==== 
-  * HTML 4 comes in three versions : +  * The head element of a page is not displayed. It contains information about the document
-    * Strict which contains no deprecated elements or frames <code html> +  * It may only contain the following tagsbase (base url for links), link (external resources e.g.style-sheets), meta, title, style, and script.
-<!DOCTYPE HTML PUBLIC +
-"-//W3C//DTD HTML 4.01//EN" +
-"http://www.w3.org/TR/html4/strict.dtd"></code> +
-    * Transitional which includes deprecated elements <code html> <!DOCTYPE HTML PUBLIC +
-"-//W3C//DTD HTML 4.01 Transitional//EN" +
-"http://www.w3.org/TR/html4/loose.dtd"></code> +
-    * Frameset which includes deprecated elements and frames <code html><!DOCTYPE HTML PUBLIC +
-"-//W3C//DTD HTML 4.01 Frameset//EN" +
-"http://www.w3.org/TR/html4/frameset.dtd"></code>+
   * Example style declaration in head <code html>   * Example style declaration in head <code html>
 <head> <head>
Line 131: Line 145:
   </style>   </style>
 </head> </code> </head> </code>
-  * <div> and <span> are used to group elements to format them with a style. <divalso divides a page into sections.+  * Examples of the meta tag <code html> 
 +<meta name="keywords" content="HTML, DHTM" /> 
 +<meta name="description" content="Free tutorials" /> 
 +<meta name="revised" content="My Name, 6/10/99" /> 
 +<meta http-equiv="refresh" content="5" /> 
 +</code>   
 + 
 +==== Advanced HTML ==== 
 + 
 +  * <div> is used to group elements or divide a page into sections. <span> is used for selecting a part of an element. Both can be used for formatting purposes. 
 +  * A simple script in a webpage <code html> 
 +<body>  
 +  <script type="text/javascript"> 
 +    <!-- //to prevent display in older browsers 
 +    document.write("Hello World!"
 +    //--> 
 +  </script> 
 +  <noscript>Javascript not supported</noscript> 
 + </body> </code> 
 +  * An object element with child param elements can also be used to embed content. 
 +  * accesskey (character) and tabindex (integer) attributes can be used to make a page keyboard-friendly. 
 + 
 +  * Events allow scripts to be registered for certain user actions. There are four types of events : 
 +    * window events are only valid in a body or frameset element: onload, onunload. 
 +    * form element events: onchange, onselect, onreset, onsubmit, onblur, onfocus 
 +    * keyboard events: onkeydown, onkeypress, onkeyup 
 +    * mouse events: onclick, ondblclick, onmousedown, onmousemove, onmouseup, onmouseover, onmouseup 
 + 
 +==== XHTML ==== 
 +  * XHTML is a stricter and cleaner replacement for HTML defined as an XML format
 +  * XHTML requires elements to be closed, properly nested and lowercase. 
 +  * Documents must have a DOCTYPE declaration and only a single root element. They must have a head with a title and a body. 
 +  * Attributes must be lowercase with quoted values and must have values (e.g. checked="checked"). 
 +  * id replaces the name attribute, xml:lang replaces lang but both should be used for compatibility. 
 +  * There are three XHTML variations 
 +    * Strict - No presentational attributes allowed <code html> 
 +<!DOCTYPE html 
 +PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"  
 +"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"></code> 
 +    * Transitional - Presentational attributes allowed but no frames <code html><!DOCTYPE html 
 +PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
 +"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"></code> 
 +    * Frameset - Allows presentational attributes and frames <code html> 
 +<!DOCTYPE html 
 +PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" 
 +"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd"></code> 
 + 
Recent changes RSS feed Creative Commons License Donate Minima Template by Wikidesign Driven by DokuWiki