Page 99 - CodePilot V5.0 C6
P. 99
TAGS AND ATTRIBUTES
Tags are HTML building blocks used to structure web content like headings, paragraphs, links and
images. Enclosed in < >, each tag has a specific meaning interpreted by the browser.
Syntax:
<TAG_NAME> content </TAG_NAME>
For example:
<P> My cat is very grumpy </P>
Opening Tag Content Closing Tag
Most HTML tags have opening and closing tags. The opening tag < > starts an element and the
closing tag </ > ends it. Together with the content, they form an element.
TYPES OF TAGS
HTML5 tags can be classified into two types:
Container Tags: Container tags have opening and closing tags that enclose data. The closing
tag has a forward slash. Examples include <P>…</P>, <HTML>…</HTML>, <HEAD>…</HEAD>,
<BODY>…</BODY> and <H1>…</H1>.
Empty Tags: An empty tag is a tag that does not have a closing tag. It is used by itself to add
something to a web page. Examples of empty tags include <HR> and <BR>.
NESTING TAGS
Nesting tags means placing one HTML tag inside another. Tags follow LIFO (Last In First Out):
the last opened tag must be closed first.
For example:
<BODY> <H1> Web Browser </H1> </BODY>
ATTRIBUTE
An attribute adds extra information to an HTML tag. It has a name and value, is placed in the
opening tag and the value is enclosed in quotes.
Syntax:
<TAG_NAME ATTRIBUTE_NAME="VALUE">...</TAG_NAME>
RULES FOR WRITING HTML5 CODE
Some of the basic rules for writing HTML5 code are:
Content should be placed between opening and closing tags.
97
HTML5–Getting Started

