Professional Documents
Culture Documents
Web Page Design: Opening and Closing Tags
Web Page Design: Opening and Closing Tags
Web Page Design: Opening and Closing Tags
Lesson 1: Tags
<html>
</html>
Notice the / in the closing tag? All closing tags must have this slash. You know
why? Because it's a closing tag, that's why. Below the opening html tag come
the opening and closing head tags:
<head> </head>
The head tag doesn't have any affect on what appears on the web page, it's job
is to hold certain other types of tags, one being the title tag:
Ah, look at that, there's some text between the opening and closing title tags,
this is where the title of a web page is entered, it will appear in the browser's title
bar:
1
Next comes the closing head tag. Remember, a closing tag has a slash ( this
thing / ). So this is what the code should look like so far:
<html>
<head>
<title>My First Webpage</title>
</head>
Now let's get to putting something on the webpage. Everything that is seen on
web pages is found between the opening and closing body tags:
<body> </body>
Example:
<html>
<head>
<title>My First Webpage</title>
</head>>
<body>
Look Ma, I'm Making my first webpage
</body>
</html>
Notice in the example that the closing html tag was added to the code. This
means we are finished (at least for now), so save your code following the
instructions given in the introduction of this tutorial.
Curious to see how the webpage looks? Open the webpage in your browser and
have a look. See? The text between the body tags is what shows on the
webpage. In the next lesson you will be introduced to more tags and what they
do. So how about it, you ready for lesson two?
2
Lesson 2: Block Tags
Making Headings
Let’s make the web page a little more eye catching by adding a large, bold
heading using the heading tags:
<h1></h1>
Remember from the previous lesson, things which appear on web pages are
enclosed between the opening and closing body tags, that also includes other
tags which affect how things are seen on web pages:
<body>
<h1>Learning HTML</h1>
</body>
The number 1 beside the letter h determines how large the heading will be. Any
number from 1 to 6 can be used, 1 makes the largest heading, and 6 makes the
smallest.
Heading tags belong to what are called “block” tags. These kind of tags don’t
allow any outside text to line up beside them, you will see the effect in a moment
but first let’s see how our HTML file is shaping up:
<html>
<head>
<title>My First Webpage</title>
</head>
<body>
<h1>Learning HTML</h1> Look Ma, I'm making a webpage!
</body>
</html>
Open your web page and this is what it should look like:
3
See how the text outside the h1 tags is on a separate line? This is what block
tags do, they force the stuff they don’t enclose to be on a separate line. Another
block tag is the paragraph tag:
<p></p>
Any text put between the opening and closing p tags makes one paragraph.
Hitting the “Enter” key has no effect on web pages, to start a new line within a
paragraph the br tag is needed:
<br>
The br tag is one of the few HTML tags which does not have a corresponding
closing tag. These kind of tags are called “single” tags. Here is an example of
how the br tag can be used in a paragraph:
Look Ma,
I’m making a webpage!
4
Lesson 3: Inline Tags
Formatting Text
Words within a sentence or paragraph can be made bold with the strong tag like
so:
<p>
One word in this sentence will be bold <strong> guess</strong> which one?
</p>
Did you pick "guess"? Then you passed the grade, give yourself a pat on the
back.
The strong and em tags belong to a group of tags known as “inline” tags, these
kind of tags don’t force text to start on a separate line the way block tags do.
They can be used together to make text both bold and italicized:
It doesn’t matter which tag is used first but it is important to note that when using
combination of tags their corresponding closing tag should be listed in the correct
order, if the order starts with the opening em tag, it should end with the closing
em tag, for example:
<span></span>
5
Lesson 4: Attributes
6
The style attribute’s job is to hold CSS code, that’s the stuff in the quotation
marks. In the above example it's telling the h1 tag to center the text on the web
page. Notice that there is a colon between text-align and center and at the end
of center there is a semi colon. This is how CSS commands are structured.
The text in our example can further be changed by adding another CSS
command to the style attribute:
The result would be red text centered on the web page. An unlimited amount of
CSS commands can be added to the style attribute as long as they are enclosed
between the quotation marks and each command ends with a semi colon.
The style attribute can be put in any opening tag to change some aspect of the
tag, for instance when used with the body tag, all the text on a web page can be
displayed in a different font:
<body style="font-family:arial;">
The font-family command changes the text font, in this example it’s in Arial
style.Adding a CSS background command in the body tag changes the page's
background color:
<body style="background:red;">
That would give your web page a red background (you don’t really want a red
web page do you?). Colors can be specified by either using the name of the color
or its color code, for example #ff0000 is the color code for red:
<body style="background:#ff0000;">
The number sign, # must be included in front of the code when specifying colors
by their color code.
7
Size of text is determined by the number, the larger the number the bigger the
text, px stands for "pixels".
CSS commands are usually put in a CSS file called an "external style sheet" but
the style attribute is a simple way to use CSS directly in the HTML code until you
get to know more about CSS.
Lesson 5: Graphics
<img src="filename.jpg">
The img stands for "image", src is an attribute, it tells the browser where to find
the picture. The stuff in the quotation marks is the file name of the graphic,
replace filename.jpg with the file name of your picture and be sure it’s between
the quotes.
Note
The file name of the picture must also include its format, e.g. jpg as in the above
example. More on image format later in this lesson.
To keep things simple, for now store your pictures in the same place as your web
pages, for example if you keep your HTML files in a folder called "my pages", put
your pictures there too.
Every picture on a web page has its very own img tag:
<img src="button.gif">
<img src="button2.gif">
If an img tag is enclosed between the opening and closing p tags, the other
image will start on a new line:
8
<p><img src="button.gif"></p>
<img src="button2.gif">
Result:
Give your pictures a description by adding an alt attribute to the img tag like so:
The alt attribute will make the description appear if a browser does not display
images. In some browsers the description will also pop up when a mouse pointer
is moved over the picture.
Image Format
Pictures on the web are usually either in gif or jpg format. The gif format is
mostly used for pictures with solid blocks of color such as charts, or when an
image requires a transparent background. The jpg format is suitable for pictures
with subtle color changes such as photos.
Lesson 6: Links
<a></a>
The anchor tag comes with the href attribute. It means “hpertext reference”. This
attribute tells the browser where to find a link. A link to a web page within the
same directory (folder) of the website would look like this:
The href attribute contains the file name of the destination web page. The file
name is enclosed in quotation marks and it includes the html extension. The text
9
between the opening and closing a tag is the link people will click. To keep things
simple, for now place all your web pages in the same folder (directory).
Linking to another website is done by putting the entire website address (url) into
the href attribute:
Be sure that http:// is included in the website address. Turning an image into a
link is done by surrounding the img tag with the opening and closing a tags:
Replace filename.html with the file name of the page or website address, and
replace filename.jpg with the file name of your picture.
By default image links have a blue border around them, the border can be
removed by adding the style attribute with a CSS border command:
Email Link
Putting an email link on web pages is done by entering the email address in the
href attribute preceded by a mailto: command like so:
Notice there is a colon between mailto and the email address and that they are
enclosed in quotation marks. By the way, in case you haven’t noticed by now,
there is a space between the a and the href attribute.
And that's how to make links, next we're going to make a list in lesson 7.
<ul></ul>
The ul stands for “unordered list”, it will get you bulleted text, you know, a dot
beside the text. The opening ul tag starts the list and the closing ul tag ends the
list, in between goes the text surrounded by the opening and closing "list item"
tag:
<li></li>
10
Example:
<ul>
<li>Beagle</li>
<li>Terrier</li>
<li>Chihuahua</li>
</ul>
Result:
Beagle
Terrier
Chihuahua
Any number of items can be added to the list as long as they are enclosed by the
opening and closing li tags. And that's how to make a list, let's now move on to
making tables, don't worry no carpentry skills required. Next: lesson 8.
Lesson 8: Tables
Making A Table
We’re talking here tables for holding data not the dinner table. Tables are useful
in laying out the design of web pages so it’s well worth the time to learn how to
make them. A table starts and ends with the table tag:
<table></table>
Between the opening and closing table tags go a couple of other tags, the tr tag:
<tr></tr>
It stands for “table row” and will make up one row across the table. Between the
tr tags are found the td tags:
<td></td>
The td stands for “table data” it forms one box called a “cell” which contains
content seen on the web page such as text or graphics. Here’s how the table
code is put together:
11
<table border="1">
<tr>
<td>Beagle</td>
<td>Chihuahua</td>
</tr>
<tr>
<td>Terrier</td>
<td>Collie</td>
</tr>
</table>
Putting a border attribute in the table tag will help you see how the table and
cells are formed, setting the border attribute to "0" will remove the borders
altogether.
Take a close look at the code, this table will have 2 rows with 2 cells in each row.
The stuff between the opening and closing td tags is what will be in each cell.
Note that each row is finished off with the closing tr tag. Finally the table is
finished by ending it with the closing table tag.
Result:
Beagle Chihuahua
Terrier Collie
Remember the style attribute from lesson 4? Put it into the opening td tags with
a CSS padding command to add some space around the content of the cells:
<td style="padding:10px;">Beagle</td>
Result:
Beagle Chihuahua
Terrier Collie
We can make a table larger by putting the style attribute into the opening table
tag and giving it a CSS width command:
Result:
12
Beagle Chihuahua
Terrier Collie
Add the a CSS vertical-align command to a td tag and the content of that cell
will start at the top of the cell:
<td style="vertical-align:top;">Chihuahua</td>
Result:
Beagle Chihuahua
Terrier Collie
<td style="background:silver;">Terrier</td>
Result:
Beagle Chihuahua
Terrier Collie
And that folks is how a table is put together. By now you have all the tags you
need to put together a website, I hope you enjoyed the lessons enough to buy
my book, HTML Made Easy with a free bonus CSS tutorial.
Once your website is ready for its debut on the world wide web, you will want to
know how to put it on the internet, learn how it is done in the Uploading Web
Pages tutorial.
13
Lesson 9: Frames
You can see that this page has two frames, the top frame containing the page
with the title, and the bottom frame containing the page with the sidebar and
main content. Webpages within the frames are written just like any other html file
but the page which brings them together has it's own set of html tags. Here's how
the code looks for this page:
<html>
<head>
<title>frames</title>
<head>
<frameset rows="30%,70%">
<frame src="title.html">
<frame src="main.html">
</frameset>
</html>
Notice that the html file starts out just like any other web page except there are
no body tags. In their place are the opening and closing frameset tags.
The rows attribute in the frameset tag makes horizontal frames, vertical frames
are made with the cols attribute. The numbers determine how much of the web
page the frames will take up, in the example the top frame takes 30% and the
second frame 70% of space. The percentages need to be distributed so that they
add up to 100% and notice they are enclosed in quotation marks. Each
percentage is separated by a comma.
14
Next come the frame tags, they are single tags so have no closing tag. The src
attribute is telling the browser which web page is to display in the frame by
default (when the visitor arrives on the web page). In the example the first frame
holds a web page with the file name "title.html" and the second frame holds a
web page named "main.html".
More frames can be put on a web page by adding more frame tags to the code.
To remove frame borders add the border="0" attribute into the opening
frameset tag like so:
The name of the frame can be anything, once the frame is named, the link is
directed to it through the target attribute in the anchor tags:
The target attribute told the link to send the web page into a frame named
myframe. The target attribute can also force links to break out of frames
completely and load like a regular web page when its value is set to "_top" like
so:
And that's how a web page with frames is made. So do you still want them?
15