HTML Notes
HTML Notes
HTML
As noted in the theory notes, HTML stands for Hypertext Markup Language. Hypertext is a piece
of text containing links (or hyperlinks) to other texts.
Markup language is a way of writing style and layout information within a text document. HTML is
only one such example of a markup language.
Note that HTML is a simple scripting language and is easy to learn and simple to understand.
The key commands of HTML are called “tags”.
Note that an HTML document is a simple plain text le which contains text and tags. When
viewed within a browser, the document is displayed with formatting.
HTML Editors
When working with HTML documents, you will be using HTML editors.
An HTML editor is a software application which is required to write HTML tags to create properly
formatted web pages. Remember that these web pages are viewable by any web browser.
Text Editor
This type of editor uses plaintext to type and manually format HTML tags and content. NotePad,
WordPad, TextEdit and other basic text editing programs should o er the functionality needed to
create and edit HTML documents.
HTML Tags
HTML markup tags are also known as HTML tags, and these represent various elements in an
HTML document. HTML tags are identi ed as keywords enclosed within a pair of angular
brackets, < and >.
These tags are generally paired, such as <html> and </html> to mark the beginning and end of an
HTML instruction and element.
The rst tag in the pair is known as the opening tag and the second tag is known as the closing
tag.
The closing tag is identi ed with a forward slash / ahead of the tag keyword within the angular
brackets. Although this is a general rule, there are two types of tags:
• Container tags which have a start and an end tag to their HTML element. Examples being
<b>…</b>, <p>…….</p>, etc.
• Empty tags which only have a start tag and no closing tag. These are used to introduce a
special element such as <li>, <img>, <hr> and more.
HTML elements
The content typed alongside the start and end tags is called the HTML element. For example,
fi
fi
fi
fi
fi
ff
fi
<b>Click Here</b> is one HTML element. HTML also allows for nested elements within one
another. An example can be seen as follows: <b><u>Click Here</u></b>.
Remember that the opening and closing tags should always follow a sequence, where the tags
should be closed in the reverse order that they were opened. As noted above, the <b> tag is rst
and last place.
Root element. This contains the <html> tag. It is a container tag which does not directly show on
the web page. It is used to inform the browser that the document is an HTML document. Such
examples of root elements include the doctype declaration required to render an HTML document
in the browser. <!doctype html> <html> </html> are tags comprising the root element.
Head element. This element contains information about the document and does not directly
show on the web page either. This element contains the HEAD tag which is the rst tag under the
HTML tag. Within the head element, other tags such as the TITLE tag can be found. The TITLE
tag for example displays the page title in the title bar of the browser.
Body element. This element de nes the document’s body and comes after the head element.
The body tag is used to show text, images, links, videos and more on a web page. The body tag
may contain multiple other tags within it.
The following are some important attributes of the <body> tag:
Text: This attribute speci es the colour of the text for the tag. The value can either be the
name of the colour within quotes or a speci c hexadecimal value.
Bgcolor: This speci es the background colour of the web page. Same as the text colour,
the name of the colour can be given within quotes, or a speci c hexadecimal value.
Leftmargin: This sets the left margin of the web page, and can be given as a number or
percentage.
Topmargin: This sets the margin at the top of the web page and can also be given as a
number or percentage.
Background: This attribute is used to set an image as the background of a web page.
Be careful not to use heading tags only to make text bold or bigger. Only use them for headings.
Formatting Tags
Tags which are used to give formatting e ects to the text on a web page are called formatting
tags. Some of these tags are explained now.
Comment tag
This is a container tag used to insert hidden comments in HTML code. This is used to increase
the readability of the code, as the comments do not get executed or displayed. The syntax of the
comment tag is <!- - Comment - ->
Inserting images
Images can be inserted into an HTML page with the <img> tag. Most image formats are
supported. Note that images take longer to load in a web page. Therefore the size and number of
images is important to reduce the loading time of a web page.
Image attributes: The following attributes are important to the image tag.
Src stands for the source and speci es the location of the URL of the image to be displayed in
the web page. If the image is in the same directory as the HTML document, the image name can
be used only.
Align as assumed handles the alignment of the image on a web page.
Height speci es the height of the image in pixels and can be resized in numbers or percentages.
Width speci es the width of the image in pixels and can be resized in numbers or percentages.
Border is a numeric value which sets the width of the border around the image.
Alt assigns an alternative text to be displayed if the image is not available.
Hyperlinks
Linking is the most powerful tool in HTML as it can be used to connect di erent web pages and
form a complete website. A browser highlights the identi ed text or image with colour and
underlines it to indicate that it is a hyperlink. Hyperlinks can point to any resource on the web:
another HTML document, an image, sound, movie and more.
The tag used to produce links is called the anchor tag <a> which is a container element.