<tagname>content</tagname>HTML element = HTML tags + contents within
HTML Page Structure: nested
HTML Versions
| Version | Year |
|---|---|
| HTML | 1991 |
| HTML+ | 1993 |
| HTML 2.0 | 1995 |
| HTML 3.2 | 1997 |
| HTML 4.01 | 1999 |
| XHTML | 2000 |
| HTML5 | 2012 |
<!DOCTYPE> Declaration<!DOCTYPE html>HTML 4.01
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">XHTML 1.0
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">for more, see DOCTYPE Reference
<h1> to <h6>
<p> and </p>
<a href="http://www.w3schools.com">This is a link</a>
<img src="w3schools.jpg" alt="W3Schools.com" width="104" height="142">
HTML Element = start tag + Element content + end tag<br> (line break) is an empty element without a closing tagname/value pairsQuote Attribute Values, Double style quotes: most common, single style quotes: also allowed.<hr>: horizontal line<!-- This is a comment --> : HTML Comments, will not be rendered,<!--...--> ← Ann Lau style<b>: bold, or similarly <strong><i>: italic, or similarly <em><sub>, <sup>: subscripted / superscripted<ins>: inserted text<mark>, <del><code>: Defines computer code text<kbd>: keyboard<samp>: sample computer code<var>: variable<pre>: preformatted text ♥<abbr>: abbreviation or acronym<address>: contact information for the author/owner of a document<bdo>: HTML bidirectional override element. (text direction)<blockquote> : a section that is quoted from another source<q>: inline (short) quotation<cite>: defines the title of a work<dfn>: defines a definition term#href → id<a id="tips">Useful Tips Section</a><a href="#tips">Visit the Useful Tips Section</a><a href="http://www.w3schools.com/" target="_blank">Visit W3Schools!</a><head>defines information about the document
The following tags can be added to the head section: <title>, <style>, <meta>, <link>, <script>, <noscript>, and <base>.
<base>: specifies the base URL/target for all relative URLs in a page
<head>
<base href="http://www.w3schools.com/images/" target="_blank">
</head><link>: defines the relationship between a document and an external resource most used to link to style sheets
<head>
<link rel="stylesheet" type="text/css" href="mystyle.css">
</head><style>: define style information, specify how HTML elements render
<head>
<style type="text/css">
body {background-color:yellow;}
p {color:blue;}
</style>
</head><meta>: not be displayed on the page, but will be machine parsable
<meta name="keywords" content="HTML, CSS, XML, XHTML, JavaScript"><meta name="description" content="Free Web tutorials on HTML and CSS"><meta name="author" content="Hege Refsnes"><meta http-equiv="refresh" content="30"><script>: define a client-side script, such as a JavaScript
Cascading Style Sheets
<style> element in the <head> section<p style="color:blue;margin-left:20px;">This is a paragraph.</p>style="background-color:red;"style="font-family:arial;color:red;font-size:20px;"style="text-align:center;"used if one single document has a unique style defined in the <head> section, by using the <style> tag
<head>
<style>
body {background-color:yellow;}
p {color:blue;}
</style>
</head><link> tag goes inside the <head> section (样式与页面是连接关系)
<head>
<link rel="stylesheet" type="text/css" href="mystyle.css">
</head><img> tag is empty (contains attributes only, and no closing tag)
Syntax: <img src="url" alt="some_text">
Example: <img src="smiley.gif" alt="Smiley face" width="42" height="42">
More Options
style="float:left": float to the left, not supported in HTML5mouse area:
<img src="planets.gif" width="145" height="126" alt="Planets" usemap="#planetmap">
<map name="planetmap">
<area shape="rect" coords="0,0,82,126" alt="Sun" href="sun.htm">
<area shape="circle" coords="90,58,3" alt="Mercury" href="mercur.htm">
<area shape="circle" coords="124,58,8" alt="Venus" href="venus.htm">
</map><table><tr>: table row<td>: table data<th>: table heading
<table style="width:300px">
<tr>
<td>Jill</td>
<td>Smith</td>
<td>50</td>
</tr>
<tr>
<td>Eve</td>
<td>Jackson</td>
<td>94</td>
</tr>
</table><style>
table, th, td {
border:1px solid black;
}
</style><table border="1" style="width:300px">Text Alignment
th {
text-align:left;
}Caption : <caption>
<ol>: ordered list<ul>: unordered list<dl>: description list<li>: list item<dt>: description term (term/name in a description list)<dd>: description description
<ul>
<li>Coffee</li>
<li>Milk</li>
</ul>
<ol>
<li>Coffee</li>
<li>Milk</li>
</ol>
<dl>
<dt>Coffee</dt><dd>- black hot drink</dd>
<dt>Milk</dt><dd>- white cold drink</dd>
</dl>HTML Elementsblock level elements or inline elements<h1> <p> <ul> <table> <div><b> <td> <a> <img> <span><div>: defines a section in a document (block-level)<span>: defines a section in a document (inline)<div> elements (a shortening of division)<div id="container" style="width:500px">
<p></p>
<div id="header" style="background-color:#FFA500;">
<h1 style="margin-bottom:0;">Main Title of Web Page</h1>
</div>
<p></p>
<div id="menu" style="background-color:#FFD700;height:200px;width:100px;float:left;">
<b>Menu</b><br>
HTML<br>
CSS<br>
JavaScript
</div>
<p></p>
<div id="content" style="background-color:#EEEEEE;height:200px;width:400px;float:left;">
Content goes here
</div>
<p></p>
<div id="footer" style="background-color:#FFA500;clear:both;text-align:center;">
Copyright ? W3Schools.com
</div>
<p></p>
</div>
div
<table> elements<table width="500" border="0">
<tr>
<td colspan="2" style="background-color:#FFA500;">
<h1>Main Title of Web Page</h1>
</td>
</tr>
<tr>
<td style="background-color:#FFD700;width:100px;">
<b>Menu</b><br>HTML<br>CSS<br>JavaScript
</td>
<td style="background-color:#EEEEEE;height:200px;width:400px;">
Content goes here
</td>
</tr>
<tr>
<td colspan="2" style="background-color:#FFA500;text-align:center;">
Copyright ? W3Schools.com
</td>
</tr>
</table><form><input>: most important form element
<input type="text" name="firstname">
<input type="password" name="pwd">
<input type="radio" name="sex" value="male">Male<br>
<input type="checkbox" name="vehicle" value="Bike">I have a bike<br>
<input type="button" value="Hello world!"><form name="input" action="html_form_action.asp" method="get">
Username: <input type="text" name="user">
<input type="submit" value="Submit">
</form><form action="">
<select name="cars">
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
<option value="fiat" selected>Fiat</option>
<option value="audi">Audi</option>
</select>
</form><textarea rows="10" cols="30">
The cat was playing in the garden.
</textarea>An iframe is used to display a web page within a web page, i stands for inline
<iframe src="http://bl.ocks.org/mbostock/raw/4060366/" width="1000" height="560"></iframe># sign17 standard colors black gray white red green blue orange yellow purple maroon navy olive silver lime teal fuchsia aqua
<script> tagdefine a client-side script, such as a JavaScript, e.g. <script> document.write("Hello World!") </script>
<noscript>provide an alternate content, <script>...</script><noscript>Sorry, Your Browser Doesn't Support It</noscript>
A Taste of JavaScript
document.write("<p>This is a paragraph</p>");
<button type="button" onclick="myFunction()">Click Me!</button>
document.getElementById("demo").style.color="#ff0000";Be replaced with character entities
&entity_name; or &#entity_number; e.g.
& or &, ampersand< or <, less than , non breaking spaceà, àá, áâ, âã, ãਲ ਲ਼, ਲ ਲ਼like mathematical operators, arrows, technical symbols and shapes, are not present on a normal keyboard.
HTML Entities name, independent of what character set€€€∀ ∀ ∀, ∂ ∂ ∂, ∃ ∃ ∃, ∅ ∅ ∅, ∇ ∇ ∇, ∈ ∈ ∈, ∉ ∉ ∉, ∋ ∋ ∋, ∏ ∏ ∏, ∑ ∑ ∑, α α α, β β β, γ γ γ, δ δ δ, ε ε ε, ζ ζ ζ, ← ← ←, → → →, ↑ ↑ ↑, ↓ ↓ ↓, ♣ ♣ ♣, ♥ ♥ ♥, ♦ ♦ ♦, © © ©, ® ® ®, ™ ™ ™,character encoding standard (character set): 127covers (almost) all the characters and symbols in the world.<meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1"><meta charset="UTF-8">ANSI,IOS-8859-1,Unicode is identical to ASCII for the values from 0 to 127.scheme://host.domain:port/path/filename
scheme - defines the type of Internet service.httphost - defines the domain host (the default host for http is www)domain - defines the Internet domain name, like w3schools.comport - defs the port number at the host (default port number for http:80)path - defines a path at the serverfilename - defines the name of a document/resourcehttp : HyperText Transfer Protocolhttps : Secure HTTP, All information exchanged are encryptedftp : File Transfer Protocolfile : to access files on your own computerWhat Is XHTML?
Why XHTML?
The Most Important Differences from HTML
<html> is mandatory<html>, <head>, <title>, and <body> is mandatory<br> to <br /><table width="100%"><input checked> to <input checked="checked">Refs
<bdo> - HTML (HyperText Markup Language) | MDN