HTML Basics
HTML Basics
1
MARK-UP LANGUAGES
Traditionally used to provide typesetting information to
printers where text should be indented, margin sizes,
bold text, special font sizes and styles, etc.
Word processors like MS Word, and typesetting systems
like LaTex are also forms of mark-up languages.
Rich Text Format (rtf) files are written in a mark-up text
format.
2
HYPERTEXT MARKUP
LANGUAGE ( HTML )
describes the structure of the document
provides
text and other formatting instructions to tell
the browser how to render the material.
has
evolved to version 4.01.
www.w3.org
3
WEB BROWSER
Software when connected to the Internet is able to access
documents at remote locations and display them locally
in accordance with its interpretation of markup
instructions in the document.
4
HTML DOCUMENTS
Plain text files, with extension htm or html.
The extension tells the browser interpret the file according
to HTML standards.
Use any plain text editor to create html files manually.
5
HTML EXTENSIONS
For special applications there are proprietary extensions
for the html language although they are NOT official
parts of html.
6
CASE RESTRICTIONS
html is case-insensitive, meaning that either upper or
lower case may be used.
7
BASIC HTML DOCUMENT STRUCTURE
<html> { Markup Language Type Declaration }
<head>
<title> { Descriptive Text Here }</title>
</head>
<body>
{ Main content here }
</body>
8
</html>
DOCTYPE
A pre-processor directive at the top of the document tells the
browser what kind of standards apply to the document.
9
TEMPLATE
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<title>***replace this text with course & section number and your full name </title>
</head>
<body>
<!--Begin your content specification by adding your elements here. -->
</body>
10
</html>
ELEMENTS
html documents consist of a number of elements where text is
placed in containers with a start tag and an end tag (tandem
tags)
Valid:
<p><em>This is correct nesting.</em> It is valid!</p>
12
THE HEAD (HEADER) SECTION
</title>
</body>
14
TEXT ELEMENT TAGS
15
HEADINGS – SIX (6) LEVELS
17
HTML DOCUMENT EXAMPLE
<html>
<! This is a comment line: Browser will ignore it.>
<head>
<title> HTML document example</title>
</head>
<body>
<h3> This be a heading level 3</h3>
<p>This is a sentence in this document.</p>
<p>This is another sentence.</p>
<blockquote>
<ol>
<li> List item number 1</li>
<li> List item number 2</li>
<li> List item number 3</li>
</ol>
</blockquote>
</body> 18
</html>
THE ANCHOR ELEMENT
The anchor element, the single letter a, is used to
connect or link different documents or parts of one
document.
20
GENERAL FORM:
21
EXAMPLE A (EXTERNAL):
<a href = “http://www.yorku.ca”>York University</a>
22
EXAMPLE B (LOCAL):
<a href = “rules.html”>Game Rules</a>
Causes the html file “rules.html” to replace the current
page in the browser.
23
EXAMPLE C (NOT TRANSPORTABLE):
<a href = “file://c:/myfiles/rules.htm”>Game Rules</a>
24
INTERNAL (NAMED) LINKS
Used to create a link that jumps from one point in a
document to another in the same document.
25
EXAMPLE D: INTERNAL (NAMED)
LINKS
<a name = “target”> </a>
Attributes:
src = “name….”: Identifies the file to be loaded into a
document.
align = “top”, “middle”, “bottom”, “left”, or “right”:
Positions the image in the document
27
E.G. 1
<img src = “selfie01.jpg”>
28
E.G. 2
<img src = “selfie01.gif” align = “right”>
29
E.G. 3
<img src = “selfie01.bmp” align = “middle” height =
“100” width = “200”>
32
TABLES
Row 1
Row 2
Row 3
33
TABLES
34
TABLES
A table is defined by the tandem tag container <table>
… </table> .
<td><center><b> … </b></center></td>
36
Table Format [ 3 columns x 2 Rows ]
<table>
<tr>
<th> Row Header </th> <td> Data </td> <td> Data </td> </tr>
<tr> <td> Data </td> <td> Data </td> <td> Data </td> </tr>
</table>
37
< th > and <td> Attributes:
colspan = “x” : Forces the cell to cover “x” number of columns. Default = 1.
E.G. < td colspan = “3” > . . . </td>
rowspan = “y” : Forces the cell to cover “y” number of rows. Default = 1.
font whatever = ( as desired ) : font attribute such as color, size, family, etc.
38
Other Table Options:
<thead> … </thead>
• Defines a header section. Contains <tr> elements.
• If used, it MUST precede a
<tbody> … </tbody>
• which contains the usual table rows, and this should be followed by a
footer.
<tfoot> … </tfoot>
39
More Table Format [ 3 columns x 2 Rows ]
<table>
<thead>
<tr> <th colspan = “3” align = “center”> Header </th> </tr>
</thead>
<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>
40
More Example Specifications
41
Table cells may contain many different ordinary
HTML containers, making them quite versatile as
aids in layout and design.
Including:
Images
Hypertext Links
Lengthy Text
Applets & Objects
Other tables
42
Table-in-a-table example:
<table>
<tr> <td>
<table>
<tr> <td> <img src = “somepicture.jpg”></td></tr>
<tr> <td><a href = “targetURL”>Click ME!</td></tr>
</table>
</td></tr>
</table>
43
Mailto: – Linking to your E-mail client
44
The index.html file
The file name “index.html”, or “index.htm” is reserved.
This is the file in a directory which will be used
automatically by default if a URL ends in the directory
name instead of a file name.
On most servers, the use of this file as the default helps
prevent unauthorized access to the directory.
Some servers may have a hierarchy of default file names.
45