HTML Notes
HTML Notes
HTML Notes
WEB APPLICATIONS
HTML 5
• If you have mastered this topic, you should be able to use the following terms correctly in
your assignments and exams:
• HTML
– HyperText Markup Language
– The coded format used for creating hypertext documents on the World Wide Web and
controlling how information is displayed
• HTML5
– Current version of HyperText Markup Language
– Added new elements and features
• HTML structure
I speak HTML
head
body
Start Tag
HTML Element
• New features :
> Canvas element for drawing
> Video/audio elements for media playback
> Better support for local offline storage
> New content specific elements like article,
footer, header, nav, section
> New form controls like calendar, date, time,
email, url, search
<!DOCTYPE html>
• HTML5 documents
– Source-code form
– Text editor (e.g. Notepad, Wordpad, emacs, etc.)
– .html or .htm file-name extension
– Web server
• Stores HTML5 documents
– Web browser
• Requests HTML5 documents
• HTML5 comments
– Start with <!-- and end with -->
– html element
• head element
– Head section
» Title of the document
» Style sheets and scripts
• body element
– Body section
» Page’s content the browser displays
– Start tag
• attributes (provide additional information about an element)
– name and value (separated by an equal sign)
– End tag
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Header</title>
</head>
<body>
<h1>Level 1 Header</h1>
<h2>Level 2 Header</h2>
<h3>Level 3 Header</h3>
<h4>Level 4 Header</h4>
<h5>Level 5 Header</h5>
<h6>Level 6 Header</h6>
</body>
</html>
<h1>Level 1 Header</h1>
<h2>Level 2 Header</h2>
<h3>Level 3 Header</h3>
<h4>Level 4 Header</h4>
<h5>Level 5 Header</h5>
<h6>Level 6 Header</h6>
• Hyperlink
– References other sources such as XHTML documents and images
– Both text and images can act as hyperlinks
– Created using the a (anchor) element
• Attribute href
– Specifies the location of a linked resource
• Link to e-mail addresses using mailto: URL
• <strong> tag
– Bold
• br element
– Line break
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Linking</title>
</head>
<body>
Click <a href="mailto:[email protected]">here</a> to send an email to me.
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Images</title>
</head>
<body>
<img src="princess.jpg" width="640" height="360" alt="PrincessL"/>
<img src="princess.jpg" width="356" height="200" alt="PrincessM"/>
<img src="princess.jpg" width="228" height="128" alt="PrincessS"/>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Linking</title>
</head>
<body>
<strong>Click a picture to go to that page</strong>
<br />
<br />
<a href="http://www.google.com"><img src="google.gif" /></a><br />
<a href="http://www.yahoo.com"><img src="yahoo.gif" /></a><br />
<a href="http://validator.w3.org"><img src="w3c-valid-xhtml.png" /></a>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Special Characters and More Line Breaks</title>
</head>
<body>
<p>Special Characters and More Line Breaks</p>
<hr /> <!-- inserts a horizontal rule -->
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Unordered Lists</title>
</head>
<body>
Here are my favorite fruits<br />
<ul>
<li>Banana</li>
<li>Coconut</li>
<li>Papaya</li>
</ul>
<li>Shopping </li>
<li>Programming
<!-- another nested ordered list -->
<ol>
<li>XHTML </li>
<li>C# </li>
<li>Links </li>
<li>XML </li>
<li>Keeping in touch with old friends </li>
<li>JavaScripts </li> <li>It is the technology of the future! </li>
<li>New languages </li> </ul>
</ol>
</body>
</li> </html>
</ul>
<!-- ends the nested list of line 27 -->
</li>
• Tables
– Present information
• Organize data into rows and columns
• table element
– Attribute border
• Specifies the table’s border width in pixels
– Attribute summary
• Describes the table’s contents
– Attribute caption
• Describes the table’s content and helps text-based browsers interpret table data
• table element
– Head section (header cell, defined with a thead element)
• Contains header information such as column names
• tr element (defines an individual table row)
• th element (defines the columns in the head section)
– Foot section (defined with a tfoot element)
– Table body (defined with a tbody element)
– Data cells (defined with td element)
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Creating a Basic Table</title>
</head>
<body>
<table border="1" summary="This table provides information about the price of fruit" width="40%">
<caption>
Price of Fruit
</caption>
<!-- the <thead> is the first section of a table -->
<!-- it formats the table header area -->
<thead>
<!-- <tr> inserts a table row -->
<tr>
<!-- insert a heading cell -->
<th>Fruit</th>
<th>Price</th>
</tr>
</thead>
<!-- the <tfoot> is the last section of a table -->
<!-- it formats the table footer -->
<tfoot>
<tr>
<th>Total</th>
<th>$3.75</th>
</tr>
</tfoot>
<tr>
<td>Pineapple</td>
<td>$2.00</td>
</tr>
</table>
</body>
</html>
• Element colgroup
– Groups and formats columns
• Element col
– Attribute align
• Determines the alignment of text in the column
– Attribute span
• Determines how many columns the col element formats
• rowspan and colspan
– Specify the number of rows or columns occupied by a cell
– valign
• Aligns data vertically
• One of the four values: “top”, “middle”, “bottom”, “baseline”
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Page</title>
</head>
<body>
<h1>Table Example Page</h1>
<table border="1">
<caption> Here is a more complex sample table.</caption>
<!-- <colgroup> and <col> tags are used to format entire columns -->
<colgroup>
<!-- span attribute determines how many columns the <col> tag affects -->
<col align="right" />
</colgroup>
<thead>
<!-- rowspans and colspans merge the specified number of cells vertically or horizontally -->
<tr>
<th rowspan="2"><!-- merge two rows --><img src="shrek.gif" height="192" /> </th>
<th colspan="4" valign="top"> <!-- merge four columns -->
<h1>Shrek</h1><br />
<p>As for 2007</p>
</th>
</tr>
<tr valign="bottom">
<th>Shrek 1 (2001)</th>
<th>Shrek 2 (2004)</th>
<th>Shrek 3 (2007)</th>
<th>Shrek 4 (?)</th>
</tr>
</thead>
<tr>
<th>VCD</th>
<td>Available</td>
<td>Available</td>
<td>Not Available</td>
<td>Not Available</td>
</tr>
<tr>
<th>DVD</th>
<td>Available</td>
<td>Available</td>
<td>Not Available</td>
<td>Not Available</td>
</tr>
</table>
</body>
</html>
• Element form
– Attribute method
• Specifies how the form’s data is sent to Web server
• method = “post”
– Appends form data to the browser request
• method = “get”
– Appends form data directly to the end of the URL
– Attribute action
• Specifies the URL of a script on the Web server
– input
• Specifies data to provide to the script that processes the form
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Page</title>
</head>
<body>
<h1>
Feedback Form</h1>
<p>
Please fill out this form to help us improve our site.</p>
<!-- this tag starts the form, gives the -->
<!-- method of sending information and the -->
<!-- location of form scripts -->
• Element textarea
– Inserts a multiline text box (text area)
– Attribute rows
• Specifies the number of rows
– Attribute cols
• Specifies the number columns
– Input “password”
• Inserts a password box with the specified size
• Element checkbox
– Enable users to select from a set of options
• Element select
– Provides a drop-down list of items
Element option
– Adds items to the drop-down list
• HTML5 structure
• HTML5 elements
• Images
• Links
• Table
• Form
Q&A
Module Code & Module Title Slide Title SLIDE 63