Intro To HTML
Intro To HTML
A PAIRED tag :
<tag attribute="value"> data </tag>
<font face="arial"> font type arial </font>
Free:
Sublime Text
NetBeans
Eclipse
Notepad++
To pay
Dreamweaver
Open a notepad document.
Put in the following tags
<html>
Hello World!!!
</html>
Save the document in any folder with the name
HelloWorld.html
Run the file by double-clicking on it so that it
opens in a browser.
Attributes
Only placed in the opening tag (not in the closing
tag)
Use one or multiple attributes in a single tag
separated by spaces
Values
Text or numeric to further describe attributes
Some values are case-sensitive
Values should be enclosed in straight quotes ( ""),
not curly ones ( “ ” )
Comments are delimited by <!-- and -->
<!– this is a comment -->
<body>
<!--
this is
a comment
-->
</body>
First and last tags
The HEAD section
must come before the BODY section
contains generic information about the document
Elements specified in the HEAD section can include
– title, link, script, style
The BODY section
contains the content of the document (text, images
etc)
this content is structured by other tags
<html>…</html>
<head>…</head> (Header)
Not all browsers require this tag. Contains information about the
document
<title>…</title>
The text contained within these tags appears in your browser’s
title bar
<body>…</body>
Required. All of the information is contained between these tags.
<p>…</p> (Paragraph)
Used to create a new paragraph (inserts a new line and carriage
return on your page). The </p> Closing tag is optional. It is
required when using attributes with the <p> tag
<!DOCTYPE html PUBLIC "-//w3c/dtd html 4.0 final//en">
<html>
<head>
<title>Exercise 4-1</title>
</head>
<body>
<h1>Welcome</h1>
<p>This is the start of a new paragraph. You can just keep
on typing and typing and this is still part of the same
paragraph.
</p>
<p>This is the start of another paragraph. </p>
</body>
</html>
<!DOCTYPE html PUBLIC "-//w3c/dtd html 4.0
final//en">
The <!DOCTYPE> element should be used as the
first line of all HTML documents.
Validation programs might use this construct when
determining the correctness of an HTML document.
The DOCTYPE declaration defines the document
type.
The "html" refers to the <html> root tag in the
document.
PUBLIC points to the document type definition that
is recorded with the International Standards
Organization.
Six levels of importance <h1>...<h6>
Use headings to divide document into sections
<html>
<head>
<title>Headings</title>
</head>
<body>
<h2>Chapter 1</h2>
<h3>1. Introduction</h3>
This is the introduction
<h3>2. Next section</h3>
This is the next section
<h4>2.1 A subsection</h4>
This is a subsection
</body>
</html>
Descriptive elements affect the <body>
appearance of text depending on A <em>fascinating</em>
how the text is described subject that I
• <em></em> emphasis, usually with <strong>must</strong>
italics understand
</body>
• <strong></strong> strong,
usually with bold
• <cite></cite> citation, usually in
italics
• <code></code> usually results in
monotype spacing
• <boldface></boldface>
• <big></big> bigger font than surrounding text
• <small></small> smaller font than surrounding text
• <i></i> italics
• <s></s> strikethrough
• <sub></sub> subscripts
• <sup></sup> superscripts
• <span></span> delimits text for stylesheet control
• <div></div> delimits blocks of text for stylesheet
control
<font> attributes
• face - name of font (must be installed)
– "arial", "times", "verdana", "helvetica"
• size - absolute size (1-7), or relative to previous text
– "2", "5", "7", "+1", "-2"...
• color - hexadecimal RGB, or a named color
– "3399dd", "blue", "red"
• weight - boldness from 100, 200, ..., 900
– "100", "300", "900"
e.g.
<font>…</font>
Allows you to control how your text is
displayed.
WIDTH:
Used to control the width of items like
horizontal rules. (Specified in either pixels or
percentage %)
ALIGN:
Allows you to control which way to align text and
objects using values of "left", "right" or "center”
<html>
<!-- Notice how you can put tags either above or along side one
another //-->
<head>
<title>Exercise 4-4</title>
</head>
<body>
<font size= "4" face = "Arial">
<div align= "center"><h1>Welcome</h1></div>
<p>Learning HTML is pretty easy, isn’t it?</p>
</font>
<hr width="70%" align="center" />
<p>Note that the ALIGN attribute that can be used to center
text</p>
</body>
</html>
Color can be specified in 3 ways:
Standard colors (blue, red, black, white)
Hexadecimal (#FFFFFF, #99FF66)
Decimal (255,255,255 or 0,0,0)
• Example of web color chart:
http://html-color-codes.com/rgb.html
e.g :
<body bgcolor="#994422">
img element <img />
src attribute
Specifies the location of the image file
width and height
WIDTH
· Specifies the width of the image in pixels, as you want it displayed on your web page. It
may be different from the dimensions of the picture.
HEIGHT
Specifies the height of the image in pixels, as you want it displayed on your web page. It may
be different from the dimensions of the picture.
ALT
Very important. Specifies what text you want displayed for people whose browsers don’t
support graphics or for people who’ve turned them off in their browser settings.
BORDER
Adds a border.
Used the same as the border attribute used in Tables.
Measured in pixels.
ALIGN
Specifies the image alignment, can be “top, bottom, middle, left, or right”
There are 4 places you might want to link to:
1) Another web page in same folder you are linking
FROM.
2) Another web page in a different folder
The folder can be beside, above or below the one
you are linking from.
3) Another web page on a different server (another
website)
4) A specific location on the current web page
Links are defined by the <a> Anchor tag and consist of
two main parts: the target source specified by the
HREF attribute and the actual document needed to
create the "hotspot“.
<a>…</a> (Anchor)
NAME
Use this to give names to locations on a page
Use the pound sign ( # ) to reference a named
location
<!DOCTYPE html PUBLIC "-//w3c/dtd html 4.0 1 teaspoon dried rosemary<br />
final//en"> 2 tablespoons Parmesan cheese <br />
<!-- Linking to locations on the same page //-->
1 cup chopped onions<br />
<html> <head> <br /><br />
<title>Exercise 5</title> <a href="#Home">Top of Page</a>
</head> <br /><br /><br /><br /><br /><br /><br /><br />
<div align="center"><body><h1> <h3><a name="Chicken">Great Chicken</a></h3>
<a name="Home">Recipes R' Us</a></h1> 2 diced tomatoes<br />
<hr />
1 tablespoon fresh basil<br />
<!– Links to various sections of the page //-->
1 teaspoon olive oil<br />
<a href="#Pasta">Great Pasta</a><br />
<br /><br />
<a href="#Steak">Great Meat Loaf</a><br />
<a href="#Home">Top of Page</a>
<a href="#Chicken">Great Chicken</a><br /> <br /><br /><br /><br /><br /><br /><br /><br />
<hr /> <br /><br /><br /><br /><br /><br /><br /><br />
<br /><br /><br /><br /><br /><br /><br /><br /> <br /><br /><br /><br /><br /><br /><br /><br />
<h3><a name="Pasta">Great Pasta</a></h3> </div>
1 pound pasta<br /> </body>
2 teaspoons olive oil<br />
</html>
1 cup chopped roasted pepper<br />
<br /><br />
<a href="#Home">Top of Page</a>
<br /><br /><br /><br /><br /><br /><br /><br />
<h3><a name="Steak">Great Meat Loaf</a></h3>
You just reference the name of the .html file
you want to link to in your anchor tag.
<html> 1 cup chopped roasted pepper<br />
<body>
</body>
<head> </html>
</head>
<div align="center"><body><h1><a
name="Home">Recipes R' Us</h1></a>
<hr />
<a href="#Pasta">Great Pasta</a><br />
<a href="#Steak">Great Meat Loaf</a><br />
<a href="#Chicken">Great Chicken</a><br />
<hr /> <br />
<a href="contact.htm">Contact us</a><br />
<br /><br /><br /><br /><br /><br /><br /><br
/>
<h3><a name="Pasta">Great Pasta</a></h3>
1 pound pasta<br />
2 teaspoons olive oil<br />
<html>
<body>
<head>
</head>
<div align="center"><body><h1><a
name="Home">Home</h1></a>
<hr />
<a href="http://www.cut.ac.zw">Chinhoyi
University</a><br />
<a href="http://www.google.co.zw">Google</a><br />
<br /><br /><br /><br /><br /><br /><br /><br />
</body>
</html>
Supposing that the folder is parallel (having the same
parent) to the one you’ve been working in.
The folder name needs to precede the file name.
IMPORTANT – A Backslash precedes the folder name to
access a file in a parallel folder or any other folder at
the same level or above the one you are linking
FROM. The whole path name should always be
included.
NOTE: Different browsers might react differently to
link syntax as described above. The most reliable way
to link to a document in another folder is to use the
Absolute address. e.g. <a
href="http://www.domainname.com/Folder2/contact.
htm">Contact us</a>
<html>
<body>
</body>
</html>
<html> <br /><br /><br /><br /><br /><br /><br
<body> /><br />
<h3><a name ="Pasta">Great
Pasta</a></h3>
<div align="center"><body><h1><a name =
"Home">Recipes R' Us</h1></a> 1 pound pasta<br />
<hr /> 2 teaspoons olive oil<br />
<a href="#Pasta">Great Pasta</a><br />
<a href="#Steak">Great Meat Loaf</a><br </body>
/> </html>
<a href="#Chicken">Great Chicken</a><br
/>
<hr />
<br />
<!-- <a href="contact.htm">Contact
us</a><br /> //-->
<a
href="..\SampleFiles2\contact.htm">C
ontact us</a><br />
The ..\ tells the browser to navigate up from
where it is.
Tags for Creating Tables
<table>…</table>
Defines the table structure
<caption>…</caption>
Creates a title for a table. (By default, this title appears above
the table.)
BGCOLOR
Creates a background color
BORDER
Creates a border around a table
BORDERCOLOR
Adds a color to the border
COLSPAN
Makes a row cross multiple columns
ROWSPAN
Makes a column cross multiple rows
CELLPADDING
<!DOCTYPE html PUBLIC "-//w3c/dtd html 4.0 final//en"> </tr>
<html> <!-- Row #2 //-->
<head> <tr align="center">
<title>Tables</title> <td>Ziti</td>
</head> <td>Steak</td>
<body> <td>Swordfish</td>
<div align="center"><h1>Recipes R' US</h1></div> </tr>
<!-- Row #3 //-->
<table align="center" bgcolor="lavender" border="1" <tr align="center">
bordercolor="black" cellpadding="8">
<td>Ravioli</td>
<td>Pork</td>
<caption><b>Select a Recipe</b></caption>
<td>Tuna</td>
</tr>
<!-- New Row //-->
<tr align="center">
<tr align="center">
<td rowspan="4">It's Good Food</td> <td colspan="4"><b>Eat Healthy</b></td>
<th>Pasta</th>
</tr>
<th>Meat</th>
<th>Fish</th>
</table>
</tr> </body>
<!-- Row #1 //--> </html>
<tr align="center">
<td>Spaghetti</td>
<td><a href="Chicken">Chicken</a></td>
<td>Salmon</td>
<body bgcolor="skyblue"> <tr align="center">
<div align="center"><h1>Recipes R' <td>Ziti</td>
US</h1></div> <td>Steak</td>
<td>Swordfish</td>
<table align="center" bgcolor="PINK" border="1" </tr>
bordercolor="black" cellpadding="8">
<!-- Row #3 //-->
<tr align="center">
<caption><b>Select a Recipe</b></caption>
<td><img src="cake.png" height= "50"
<!-- New Row //--> width="50" ALT="Piece of
<tr align="center"> cake"/><br/>Cake</td>
<td rowspan="4">It's Good Food</td> <td><img src="pig.png" height= "50"
<th>Pasta</th> width="50" border="2"/><br/>Pork</td>
<td>Salmon</td> </body>
</tr>
<!-- Row #2 //-->
You simply need to combine the Anchor tag with the Image tag.
<html>
<head>
<title>Thumbnail Images</title>
</head>
<body>
<a href="chat.png">
<img src="chat.png" height="40" width="40" border="0"
alt="Thumbnail of Chat" />
</a>
</body>
</html>
Make use of the ALIGN attribute as shown below.
<html>
<head>
<title>Thumbnail Images</title>
</head>
<body>
<a href="chat.png">
<img src="chat.png" height="60" width="60" border="1" alt="Thumbnail of Chat"
align="right"/>
</a>
</body>
</html>
Numerous tags exist that allow you to:
Specify the layout of your web-site.
Specify the formatting of the web-site.
Embed different kinds of objects such as links, videos and
animations
The following were obtained from
https://www.w3schools.com/tags/ where usage
examples are also available