Getting Started With HTML
Getting Started With HTML
COMPUTER APPLICATIONS
TECHNOLOGY
COURSE
GETTING STARTED WITH
HTML WEB DEVELOPMENT
COMPILED BY
MICHELLE MEYER
Page 2 of 19
Contents
Open a new text file in Notepad. Click File > Save as. Give your web page an
appropriate name and add the extension .html manually. I will name the page
home.html.
home.html
Now you are ready to begin coding. Make use of the HTML Tag Sheet on page
19 to help you with your tags and attributes.
First open the file in Notepad or any other text-based editor. You need to right
click and use the open with option. Also open the file in any web browser,
such as Google Chrome or Firefox. Fit the windows, so you can see both
windows at the same time. See the screenshot below:
Webpage Structure
<html>
<head>
<title> Rotti Home </title>
</head>
<body>
A Rottweiler is a dog….
</body>
</html>
Note that for every opening tag, a closing tag must be provided. The closing
tag has a / before the tag. Angle brackets are used to indicate a tag. The
<head> and <title> tags are used to indicate what should appear in the tab at
the top of the webpage. In this case, the words Rotti Home will appear.
▪ Type the text above (from <html> to </html>) in your new text document
that you created.
▪ Save the file (<Ctrl><S> is the shortcut).
▪ Click anywhere on the web browser window.
▪ Press the F5 key or click on the webpage refresh button. This should
happen:
Everything you do in the text editor (right) will appear in your browser (left)
after you saved the file and refreshed the browser. I suggest you do this after
every change you make – it is easier to find a mistake and fix it if you do this.
Pressing enter to create a new paragraph in your HTML document will not
work. You must therefore use the opening and closing paragraph <p> </p>
tags to indicate the start and end of a paragraph. Note how the paragraph,
bold, italics and underline tags are used in the screenshot below and how it
affects the text.
The paragraph tag has one common attribute, Align, which will change the
alignment of the paragraph (left, centre or right). The attributes follow the tag
inside the angle brackets and is then defined with an = equal sign and the
instruction in quotation marks (" "). Example: <p align = "center"> </p> - note
the American spelling of centre is used.
The self-closing break <br/> (note the / is at the end) is equivalent to pressing
the enter key once. Therefore <br/><br/> will have the same effect as the
paragraph tags.
Face will change the font type, for example Arial, Bookman Old Style,
Jokerman, etc. Note that you must use fonts that are commonly found on
most computers – if a font is not installed on someone else’s computer, they
will not be able to view the webpage as you have created it.
Color (note the American spelling) will change the colour of the font. Colours
are defined by the name or colour code of the colour, example: yellow or
#FFFF00.
Example:
Horizontal Lines
You can create a line by using the self-closing horizontal rule <hr/> tag. This
tag has four common attributes:
Width, measured in percentage (of the window) or pixels, will indicate how
long the line must be.
Align will indicate if the line must be left or right aligned. The default value is
centre, and therefore doesn’t need to be specified.
Examples:
Note the difference between the four lines, especially the difference between a
width of 50 pixels and 50 percent. Line 3 fills half (50%) of the window.
Heading Styles
You get six different heading style tags, namely <h1></h1>, <h2></h2> …
<h6></h6>. You can apply the align attribute to left, centre or right align the
headings.
Note how the heading styles are bold and left aligned by default.
You need to add the <font> tag to change the type or colour of the font. Once
again, notice the reverse order of the opening and closing tags.
Page Setup
The Body tag is used to define the pre-set rules for your page. The following
attributes are applicable to the <body> tag.
Background will allow you to use an image as a background. Note that your
image must have the correct file name and file extension in quotation marks.
The image must also be in the same folder as your HTML file – if not, the full
path of the image must be provided.
Example: <body background = "logo.jpg"> </body>
Text will change the colour of all the text on the webpage.
Example: <body text = "green"> </body>
Ordered Lists
An ordered list is a numbered list. The tags <ol> and </ol> indents a list and
adds automatic numbering to it. The <li> and </li> tags define every item on
the list. See the example below:
You may define the numbered list type by using the Type attribute.
<ol type = "a"> will number the list with lowercase letters.
<ol type = "A"> will number the list with uppercase letters.
<ol type = "i"> will number the list with lowercase Roman numerals.
<ol type = "I"> will number the list with uppercase Roman numerals.
Unordered Lists
An unordered list is a bulleted list. The tags <ul> and </ul> indents a list and
adds bullets to it. The <li> and </li> tags define every item on the list. See the
example below:
You may define the bulleted list type by using the Type attribute.
<ol type = "circle"> will bullet the list with circle ○ bullets.
<ol type = "square"> will bullet the list with square ▪ bullets.
Multi-level Lists
Adding Images
You can add an image to your webpage by using the self-closing image <img/>
tag. The attribute that follows is the Source (src – note the letter order)
attribute.
You need to save your image in the same folder as the webpage, otherwise,
you need to add the full path of the image, which can get complicated. Also
make sure you know the correct file name and extension of your image.
Alt provides alternative text that will appear if the image doesn’t load on the
webpage.
Example: <img src = "banner.png" alt = "Rottweiler Banner"/>
Hyperlinks
The opening and closing tags associated with hyperlinks is <a> and </a>. The
attribute to define the destination of the link is Href. You can link any file on
your computer or create a link to another webpage. Once again, insert the
files you wish to link in the same folder as your HTML webpage – otherwise,
you must use the whole file path in your webpage.
Links to Websites
Links to Files
In this example, I will link the file contact us.html to the home.html page.
Instead of using text, you can use any image as a link to another website or
file. As an example, the Hills Pet Nutrition logo is going to be used to link to
their webpage. Example:
Use the following tag (example) to create a link that will take you back to the
top of your webpage:
Tables
To create a table in an HTML webpage, you need to use the opening and
closing tags <table> and </table> at the start and end of your table. The
following attributes are associated with the table tag:
Border will add a border to your table and defined in sizes 1, 2, 3, etc.
Width will define the size of the window your table should stretch across and
is given in percentages, for example 50% will fill half the window.
The table row tags (<tr> </tr>) are used to define a new row in the table.
The table heading tags (<th> </th>) will automatically bold the text and are
used to define the first row of the table.
The table data tags (<td> </td>) will insert data into the cells in the table.
Basic Tables
<tr>
<th> Gender </th>
<th> Weight </th>
</tr>
<tr>
<td> Male </td>
<td> 50 - 60kg </td>
</tr>
<tr>
<td> Female </td>
<td> 35 - 48kg </td>
</tr>
</table>
Merging Cells
Here are two examples how the Colspan and Rowspan attributes are used
with the table row <tr> tag. It is defined in numbers of columns or rows that
it should stretch the data across, i.e. 1, 2, 3, etc.
<tr>
<td colspan = "2" align = "center"> Male </td>
</tr>
<tr>
<td> Weight: 50 - 60kg </td>
<td> Size: 61 - 69cm </td>
</tr>
</table>
<tr>
<td rowspan = "2" align = "center"> Female </td>
<td> Weight: 35 - 48kg </td>
</tr>
<tr>
<td> Size: 56 - 63cm </td>
</tr>
</table>
Cell Alignment
The height of rows can be changed in the <td> tag using the Height attribute
and defined in pixels. The vertical alignment can be set using the Valign
attribute and defined as top and bottom. It is centred by default.
Example:
<td colspan = "2" align = "center" height = "50" valign = "top"> Male </td>
You can add an image in a cell in a table by inserting the image tag instead of
the text data, for example:
Basic Animations
Animated GIFs
Download any animated GIF image from the Internet and insert it like any
other image: <img src = "rottie.gif"/>
The following table provides some colour names with their codes that can be
used. The full list can be obtained from the following website:
https://www.rapidtables.com/web/color/html-color-codes.html
Source: https://www.rapidtables.com/web/color/html-color-codes.html
Common Fonts
Comments
Any text added between the tags <!-- and --> will not be shown on the page.
Do
Don’t
Page title
URL
Links to other
webpages within
website
Logo
Banner
Body
The following list contains some useful tags for quick referencing.