HTML Language
HTML Language
<body>
<p>This is 1st paragraph...</p>
<p>This is 2nd paragraph...</p>
</body>
</html>
descendants
children
html
head body
ancestors
parent
title p p
siblings
9 AC2070: Web Design & Programming
Đào Trung Kiên @ MICA Institute & Dept. of Comm. Eng., SEEE, Hanoi Univ. of Science and Technology
Formatting Tags
<p>This text is <em>emphasized</em></p>
<p>This text is <strong>strong</strong></p>
<p>This text is both
<strong><em>strong and emphasized</em></strong>
</p>
<p>This paragraph has a<br />
new line</p>
self-closing tag
Incorrect Nesting
Trailing Slash
<a href="index.html">Home</a>
Link to email
<a href="mailto://person@somewhere.com">Someone</a>
<a
To link to a file that is multiple
css/ href="css/images/background.g
subdirectories below the current
if">
main.css one, construct the full path by
including each subdirectory name
images/ (separated by slashes) before the file
3
name.
background.gif
4 Parent/Ancestor Directory To link to about.html from
members/ index.html in members, use:
4 5 Use “../” to reference a folder
<a href="../about.html">
index.html above the current one. If trying to
reference a file several levels above To link to about.html from
randyc/
6
the current one, simply string bio.html, use:
bio.html together multiple “../”.
<a href="../../about.html">
index.html
for child or grandchild directories. To link to background.gif from bio.html,
use:
about.html
1 7 <a
example.html href="../../css/images/background.gi
6 f">
images/ Root Reference To link to about.html from bio.html, use:
2
logo.gif <a href="/about.html">
An alternative approach for ancestor and
central-park.jpg sibling references is to use the so-called To link to background.gif from bio.html,
root reference approach. In this approach, use:
css/ begin the reference with the root reference
<a href="/images/background.gif">
(the “/”) and then use the same technique
main.css
as for child or grandchild directories. Note
that these will only work on the server!
images/
That is, they will not work when you test it
3
background.gif 7 out on your local machine.
Default Document To link to index.html in members from
members/
about.html, use either:
4 5 Web servers allow references to directory
index.html <a href="members">
names without file names. In such a case,
randyc/ the web server will serve the default Or
6 document, which is usually a file called
<a href="/members">
bio.html
index.html (apache) or default.html
(IIS). Again, this will only generally work on
20 the web server.
AC2070: Web Design & Programming
Đào Trung Kiên @ MICA Institute & Dept. of Comm. Eng., SEEE, Hanoi Univ. of Science and Technology
A More Complete Document
1 <!DOCTYPE html>
<html>
2 <head lang="en">
<meta charset="utf-8"> 5
3 <title>Share Your Travels -- New York - Central Park</title>
<link rel="stylesheet" href="css/main.css"> 6
<script src="js/html5shiv.js"></script> 7
</head>
<body>
<h1>Main heading goes here</h1>
4 ...
</body>
</html>
<h3>Reviews</h3>
6 <div> 7
<p>By Ricardo on <time>September 15, 2012</time></p>
<p>Easy on the HDR buddy.</p>
</div>
<div>
<p>By Susan on <time>October 1, 2012</time></p>
<p>I love Central Park.</p>
</div>
8
<ul style="list-style-type:square">
<li>Chocolate Cake</li>
<li>Black Forest Cake</li>
<li>Pineapple Cake</li>
</ul>
Row 1
Row 2 cell
Row 3
<tbody>
<tr> <th>Row Header</th> <td>Data</td> <td>Data</td> </tr>
<tr> <td>Data</td> <td>Data</td> <td>Data</td> </tr>
</tbody>
<tfoot>
<tr> <th colspan="3" align="center">Footer</th> </tr>
</tfoot>
</table>