0% found this document useful (0 votes)
2 views

HTML

HTML, or Hypertext Markup Language, is the primary language used to create and structure web pages. It utilizes various tags to format content and establish links between documents, with a typical structure including a document declaration, head, and body sections. Key attributes like id, title, class, and style enhance HTML elements, providing additional information and functionality.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

HTML

HTML, or Hypertext Markup Language, is the primary language used to create and structure web pages. It utilizes various tags to format content and establish links between documents, with a typical structure including a document declaration, head, and body sections. Key attributes like id, title, class, and style enhance HTML elements, providing additional information and functionality.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 20

1.

HTML – OVERVIEW HTML HTML

HTML stands for Hypertext Markup Language, and it is the most widely used language to
write Web Pages.

 Hypertext refers to the way in which Web pages (HTML documents) are linked
together. Thus, the link available on a webpage is called Hypertext.

 As its name suggests, HTML is a Markup Language which means you use HTML to
simply "mark-up" a text document with tags that tell a Web browser how to structure
it to display.

Originally, HTML was developed with the intent of defining the structure of documents like HTML Tags
headings, paragraphs, lists, and so forth to facilitate the sharing of scientific information
As told earlier, HTML is a markup language and makes use of various tags to format the
between researchers.
content. These tags are enclosed within angle braces <Tag Name>. Except few tags, most
Now, HTML is being widely used to format web pages with the help of different tags available of the tags have their corresponding closing tags. For example, <html> has its closing
in HTML language. tag</html> and <body> tag has its closing tag </body> tag etc.

Above example of HTML document uses the following tags:


Basic HTML Document
Tag Description
In its simplest form, following is an example of an HTML document:

<!DOCTYPE html> <!DOCTYPE...> This tag defines the document type and HTML version.

<html>
This tag encloses the complete HTML document and mainly comprises
<head>
<html> of document header which is represented by <head>...</head> and
<title>This is document title</title> document body which is represented by <body>...</body> tags.
</head>
<body> This tag represents the document's header which can keep other HTML
<head>
tags like <title>, <link> etc.
<h1>This is a heading</h1>
<p>Document content goes here.....</p>
The <title> tag is used inside the <head> tag to mention the
</body> <title>
document title.
</html>
This tag represents the document's body which keeps other HTML tags
Either you can use Try it option available at the top right corner of the code box to check the <body>
like <h1>, <div>, <p> etc.
result of this HTML code, or let's save it in an HTML file test.htm using your favorite text
editor. Finally open it using a web browser like Internet Explorer or Google Chrome, or Firefox
etc. It must show the following output: <h1> This tag represents the heading.

16 17
HTML
2. HTML – BASIC TAGS HTML

<p> This tag represents a paragraph.

To learn HTML, you will need to study various tags and understand how they behave, while
formatting a textual document. Learning HTML is simple as users have to learn the usage of
different tags in order to format the text or images to make a beautiful webpage. Heading Tags
World Wide Web Consortium (W3C) recommends to use lowercase tags starting from HTML Any document starts with a heading. You can use different sizes for your headings. HTML also
4. has six levels of headings, which use the elements <h1>, <h2>, <h3>, <h4>, <h5>, and
<h6>. While displaying any heading, browser adds one line before and one line after that
HTML Document Structure heading.

A typical HTML document will have the following structure: Example


Document declaration tag <!DOCTYPE html>
<html> <html>
<head> <head>
Document header related tags <title>Heading Example</title>
</head> </head>
<body>
<body> <h1>This is heading 1</h1>
Document body related tags <h2>This is heading 2</h2>
</body> <h3>This is heading 3</h3>
</html> <h4>This is heading 4</h4>
<h5>This is heading 5</h5>
We will study all the header and body tags in subsequent chapters, but for now let's see what
is document declaration tag. <h6>This is heading 6</h6>
</body>
The <!DOCTYPE> Declaration </html>
The <!DOCTYPE> declaration tag is used by the web browser to understand the version of
This will produce the following result:
the HTML used in the document. Current version of HTML is 5 and it makes use of the following
declaration:

<!DOCTYPE html>

There are many other declaration types which can be used in HTML document depending on
what version of HTML is being used. We will see more details on this while discussing
<!DOCTYPE...> tag along with other HTML tags.

18 19
HTML HTML

Line Break Tag


Whenever you use the <br /> element, anything following it starts from the next line. This
tag is an example of an empty element, where you do not need opening and closing tags, as
there is nothing to go in between them.

The <br /> tag has a space between the characters br and the forward slash. If you omit this
space, older browsers will have trouble rendering the line break, while if you miss the forward
slash character and just use <br> it is not valid in XHTML.

Example
<!DOCTYPE html>
<html>
<head>
Paragraph Tag <title>Line Break Example</title>

The <p> tag offers a way to structure your text into different paragraphs. Each paragraph of </head>
text should go in between an opening <p> and a closing </p> tag as shown below in the <body>
example:
<p>Hello<br />

Example You delivered your assignment on time.<br />


Thanks<br />
<!DOCTYPE html>
Mahnaz</p>
<html>
</body>
<head>
</html>
<title>Paragraph Example</title>
</head> This will produce the following result:

<body>
Hello
<p>Here is a first paragraph of text.</p> You delivered your assignment on time.
Thanks
<p>Here is a second paragraph of text.</p>
Mahnaz
<p>Here is a third paragraph of text.</p>
</body>
</html>
Centering Content
You can use <center> tag to put any content in the center of the page or any table cell.
This will produce the following result:
Example
Here is a first paragraph of text.
Here is a second paragraph of text. <!DOCTYPE html>

Here is a third paragraph of text. <html>


<head>

20 21
HTML HTML

This will produce the following result:


<title>Centring Content Example</title>
</head>
<body> This is paragraph one and should be on top
<p>This text is not in the center.</p>
<center> This is paragraph two and should be at bottom

<p>This text is in the center.</p>


</center> Again <hr /> tag is an example of the empty element, where you do not need opening and
</body> closing tags, as there is nothing to go in between them.

</html> The <hr /> element has a space between the characters hr and the forward slash. If you
omit this space, older browsers will have trouble rendering the horizontal line, while if you
This will produce the following result: miss the forward slash character and just use <hr> it is not valid in XHTML

This text is not in the center. Preserve Formatting


Sometimes, you want your text to follow the exact format of how it is written in the HTML
This text is in the center. document. In these cases, you can use the preformatted tag <pre>.

Any text between the opening <pre> tag and the closing </pre> tag will preserve the
Horizontal Lines formatting of the source document.
Horizontal lines are used to visually break-up sections of a document. The <hr> tag creates
a line from the current position in the document to the right margin and breaks the line Example
accordingly.
<!DOCTYPE html>
For example, you may want to give a line between two paragraphs as in the given example
<html>
below:
<head>
Example <title>Preserve Formatting Example</title>

<!DOCTYPE html> </head>

<html> <body>

<head> <pre>

<title>Horizontal Line Example</title> function testFunction( strText ){

</head> alert (strText)

<body> }

<p>This is paragraph one and should be on top</p> </pre>

<hr /> </body>

<p>This is paragraph two and should be at bottom</p> </html>

</body> This will produce the following result:


</html>
function testFunction( strText ){
22 23
HTML
3. HTML – ELEMENTS HTML

alert (strText)

Try using the same code without keeping it inside <pre>...</pre> tags
An HTML element is defined by a starting tag. If the element contains other content, it ends
with a closing tag, where the element name is preceded by a forward slash as shown below
Nonbreaking Spaces with few tags:

Suppose you want to use the phrase "12 Angry Men." Here, you would not want a browser to
Start Tag Content End Tag
split the "12, Angry" and "Men" across two lines:

An example of this technique appears in the movie "12 Angry Men." <p> This is paragraph content. </p>

In cases, where you do not want the client browser to break text, you should use a
<h1> This is heading content. </h1>
nonbreaking space entity &nbsp; instead of a normal space. For example, when coding the
"12 Angry Men" in a paragraph, you should use something similar to the following code:
<div> This is division content. </div>
Example
<br />
<!DOCTYPE html>
<html>
<head>
So here <p>....</p> is an HTML element, <h1>...</h1> is another HTML element. There
<title>Nonbreaking Spaces Example</title> are some HTML elements which don't need to be closed, such as <img.../>, <hr /> and
<br /> elements. These are known as void elements.
</head>
<body> HTML documents consists of a tree of these elements and they specify how HTML documents
should be built, and what kind of content should be placed in what part of an HTML document.
<p>An example of this technique appears in the movie "12&nbsp;Angry&nbsp;Men."</p>
</body>
HTML Tag vs. Element
</html>
An HTML element is defined by a starting tag. If the element contains other content, it ends
with a closing tag.

For example, <p> is starting tag of a paragraph and </p> is closing tag of the same
paragraph but <p>This is paragraph</p> is a paragraph element.

Nested HTML Elements


It is very much allowed to keep one HTML element inside another HTML element:

Example
<!DOCTYPE html>
<html>

24 25
HTML
4. HTML – ATTRIBUTES HTML

<head>

<title>Nested Elements Example</title>


</head> We have seen few HTML tags and their usage like heading tags <h1>, <h2>, paragraph tag
<body> <p> and other tags. We used them so far in their simplest form, but most of the HTML tags
can also have attributes, which are extra bits of information.
<h1>This is <i>italic</i> heading</h1>
An attribute is used to define the characteristics of an HTML element and is placed inside the
<p>This is <u>underlined</u> paragraph</p>
element's opening tag. All attributes are made up of two parts: a name and a value:
</body>
 The name is the property you want to set. For example, the paragraph <p> element
</html> in the example carries an attribute whose name is align, which you can use to indicate
the alignment of paragraph on the page.
This will display the following result:

 The value is what you want the value of the property to be set and always put within
quotations. The below example shows three possible values of align attribute: left,
This is italic heading
center and right.
This is underlined paragraph Attribute names and attribute values are case-insensitive. However, the World Wide Web
Consortium (W3C) recommends lowercase attributes/attribute values in their HTML 4
recommendation.

Example
<!DOCTYPE html>
<html>
<head>
<title>Align Attribute Example</title>
</head>
<body>
<p align="left">This is left aligned</p>
<p align="center">This is center aligned</p>
<p align="right">This is right aligned</p>
</body>
</html>

This will display the following result:

This is left aligned


This is center aligned

26 27
HTML HTML

This is right aligned <title>The title Attribute Example</title>


</head>
Core Attributes <body>
The four core attributes that can be used on the majority of HTML elements (although not all) <h3 title="Hello HTML!">Titled Heading Tag Example</h3>
are:
</body>
 Id </html>
 Title
 Class This will produce the following result:
 Style
Titled Heading Tag Example
The Id Attribute
Now try to bring your cursor over "Titled Heading Tag Example" and you will see that whatever
The id attribute of an HTML tag can be used to uniquely identify any element within an HTML title you used in your code is coming out as a tooltip of the cursor.
page. There are two primary reasons that you might want to use an id attribute on an
element:

 If an element carries an id attribute as a unique identifier, it is possible to identify just


The class Attribute
that element and its content. The class attribute is used to associate an element with a style sheet, and specifies the class
of element. You will learn more about the use of the class attribute when you will learn
 If you have two elements of the same name within a Web page (or style sheet), you Cascading Style Sheet (CSS). So for now you can avoid it.
can use the id attribute to distinguish between elements that have the same name.
The value of the attribute may also be a space-separated list of class names. For example:
We will discuss style sheet in separate tutorial. For now, let's use the id attribute to distinguish
between two paragraph elements as shown below. class="className1 className2 className3"

Example
The style Attribute
<p id="html">This para explains what is HTML</p>
The style attribute allows you to specify Cascading Style Sheet (CSS) rules within the element.
<p id="css">This para explains what is Cascading Style Sheet</p>
<!DOCTYPE html>
<html>
The title Attribute
<head>
The title attribute gives a suggested title for the element. They syntax for the title attribute
is similar as explained for id attribute: <title>The style Attribute</title>
</head>
The behavior of this attribute will depend upon the element that carries it, although it is often
displayed as a tooltip when cursor comes over the element or while the element is loading. <body>
<p style="font-family:arial; color:#FF0000;">Some text...</p>
Example </body>
<!DOCTYPE html> </html>
<html>
This will produce the following result:
<head>

28 29
HTML HTML

Some text... This is how IE 5 renders right-to-left directed text.

At this point of time, we are not learning CSS, so just let's proceed without bothering much When dir attribute is used within the <html> tag, it determines how text will be presented
about CSS. Here, you need to understand what are HTML attributes and how they can be within the entire document. When used within another tag, it controls the text's direction for
used while formatting content. just the content of that tag.

Internationalization Attributes The lang Attribute


There are three internationalization attributes, which are available for most (although not all) The lang attribute allows you to indicate the main language used in a document, but this
XHTML elements. attribute was kept in HTML only for backwards compatibility with earlier versions of HTML.
This attribute has been replaced by the xml:lang attribute in new XHTML documents.
 dir
 lang The values of the lang attribute are ISO-639 standard two-character language codes. Check
 xml:lang HTML Language Codes: ISO 639 for a complete list of language codes.

The dir Attribute


The dir attribute allows you to indicate to the browser about the direction in which the text Example
should flow. The dir attribute can take one of two values, as you can see in the table that
<!DOCTYPE html>
follows:
<html lang="en">
Value Meaning <head>
<title>English Language Page</title>
ltr Left to right (the default value)
</head>
<body>
rtl Right to left (for languages such as Hebrew or Arabic that are read right to left)
This page is using English Language
</body>
Example </html>

<!DOCTYPE html>
<html dir="rtl"> The xml:lang Attribute
<head> The xml:lang attribute is the XHTML replacement for the lang attribute. The value of
<title>Display Directions</title> thexml:lang attribute should be an ISO-639 country code as mentioned in previous section.

</head>
<body> Generic Attributes
This is how IE 5 renders right-to-left directed text. Here's a table of some other attributes that are readily usable with many of the HTML tags.

</body>
Attribute Options Function
</html>

This will produce the following result: align right, left, center Horizontally aligns tags

30 31
HTML
5. HTML – FORMATTING HTML

valign top, middle, bottom Vertically aligns tags within an HTML


element.

bgcolor numeric, hexidecimal, RGB Places a background color behind an


values element
If you use a word processor, you must be familiar with the ability to make text bold, italicized,
or underlined; these are just three of the ten options available to indicate how text can appear
background URL Places a background image behind an in HTML and XHTML.
element

Bold Text
id User Defined Names an element for use with Cascading
Anything that appears within <b>...</b> element, is displayed in bold as shown below:
Style Sheets.

class User Defined Classifies an element for use with Cascading Example
Style Sheets.
<!DOCTYPE html>
<html>
width Numeric Value Specifies the width of tables, images, or
table cells. <head>
<title>Bold Text Example</title>
height Numeric Value Specifies the height of tables, images, or </head>
table cells.
<body>
<p>The following word uses a <b>bold</b> typeface.</p>
title User Defined "Pop-up" title of the elements.
</body>
</html>
We will see related examples as we will proceed to study other HTML tags. For a complete list
This will produce the following result:
of HTML Tags and related attributes please check reference to HTML Tags List.

The following word uses a bold typeface.

Italic Text
Anything that appears within <i>...</i> element is displayed in italicized as shown below:

Example
<!DOCTYPE html>
<html>
<head>
<title>Italic Text Example</title>
</head>
32 33
HTML HTML

<body> <title>Strike Text Example</title>


<p>The following word uses a <i>italicized</i> typeface.</p> </head>
</body> <body>
</html> <p>The following word uses a <strike>strikethrough</strike> typeface.</p>
</body>
This will produce the following result:
</html>
The following word uses an italicized typeface.
This will produce the following result:

Underlined Text The following word uses a strikethrough typeface.

Anything that appears within <u>...</u> element, is displayed with underline as shown
below: Monospaced Font
The content of a <tt>...</tt> element is written in monospaced font. Most of the fonts are
Example known as variable-width fonts because different letters are of different widths (for example,
the letter 'm' is wider than the letter 'i'). In a monospaced font, however, each letter has the
<!DOCTYPE html> same width.
<html>
<head> Example
<title>Underlined Text Example</title> <!DOCTYPE html>
</head> <html>
<body> <head>
<p>The following word uses a <u>underlined</u> typeface.</p> <title>Monospaced Font Example</title>
</body> </head>
</html> <body>

This will produce the following result: <p>The following word uses a <tt>monospaced</tt> typeface.</p>
</body>
The following word uses an underlined typeface.
</html>

Strike Text This will produce the following result:

Anything that appears within <strike>...</strike> element is displayed with strikethrough, The following word uses a monospaced typeface.
which is a thin line through the text as shown below:

Example Superscript Text


<!DOCTYPE html> The content of a <sup>...</sup> element is written in superscript; the font size used is the
same size as the characters surrounding it but is displayed half a character's height above
<html>
the other characters.
<head>
34 35
HTML HTML

Example Inserted Text


<!DOCTYPE html> Anything that appears within <ins>...</ins> element is displayed as inserted text.

<html>
Example
<head>
<title>Superscript Text Example</title> <!DOCTYPE html>

</head> <html>

<body> <head>

<p>The following word uses a <sup>superscript</sup> typeface.</p> <title>Inserted Text Example</title>

</body> </head>

</html> <body>
<p>I want to drink <del>cola</del> <ins>wine</ins></p>
This will produce the following result:
</body>

The following word uses a superscript typeface. </html>

This will produce the following result:


Subscript Text
The content of a <sub>...</sub> element is written in subscript; the font size used is the
same as the characters surrounding it, but is displayed half a character's height beneath the
other characters.
Deleted Text
Example Anything that appears within <del>...</del> element, is displayed as deleted text.

<!DOCTYPE html>
Example
<html>
<head> <!DOCTYPE html>

<title>Subscript Text Example</title> <html>

</head> <head>

<body> <title>Deleted Text Example</title>

<p>The following word uses a <sub>subscript</sub> typeface.</p> </head>

</body> <body>

</html> <p>I want to drink <del>cola</del> <ins>wine</ins></p>


</body>
This will produce the following result:
</html>
The following word uses a subscript typeface.
This will produce the following result:

36 37
HTML HTML

</html>

This will produce the following result:

Larger Text The following word uses a small typeface.


The content of the <big>...</big> element is displayed one font size larger than the rest of
the text surrounding it as shown below:
Grouping Content
Example The <div> and <span> elements allow you to group together several elements to create
sections or subsections of a page.
<!DOCTYPE html>
For example, you might want to put all of the footnotes on a page within a <div> element to
<html>
indicate that all of the elements within that <div> element relate to the footnotes. You might
<head> then attach a style to this <div> element so that they appear using a special set of style
rules.
<title>Larger Text Example</title>
</head>
Example
<body>
<!DOCTYPE html>
<p>The following word uses a <big>big</big> typeface.</p>
<html>
</body>
<head>
</html>
<title>Div Tag Example</title>
This will produce the following result:
</head>

The following word uses a big typeface. <body>


<div id="menu" align="middle" >
<a href="/index.htm">HOME</a> |
Smaller Text
<a href="/about/contact_us.htm">CONTACT</a> |
The content of the <small>...</small> element is displayed one font size smaller than the
<a href="/about/index.htm">ABOUT</a>
rest of the text surrounding it as shown below:
</div>
Example
<div id="content" align="left" bgcolor="white">
<!DOCTYPE html>
<h5>Content Articles</h5>
<html>
<p>Actual content goes here.....</p>
<head>
</div>
<title>Smaller Text Example</title>
</body>
</head>
</html>
<body>
<p>The following word uses a <small>small</small> typeface.</p> This will produce the following result:
</body>
38 39
HTML
6. HTML – PHRASE TAGS HTML

HOME | CONTACT | ABOUT

CONTENT ARTICLES
Actual content goes here.....

The <span> element, on the other hand, can be used to group inline elements only. So, if The phrase tags have been desicolgned for specific purposes, though they are displayed in a
you have a part of a sentence or paragraph which you want to group together, you could use similar way as other basic tags like <b>, <i>, <pre>, and <tt>, you have seen in previous
the <span> element as follows chapter. This chapter will take you through all the important phrase tags, so let's start seeing
them one by one.
Example
<!DOCTYPE html>
Emphasized Text
<html> Anything that appears within <em>...</em> element is displayed as emphasized text.

<head>
Example
<title>Span Tag Example</title>
</head> <!DOCTYPE html>

<body> <html>

<p>This is the example of <span style="color:green">span tag</span> and the <span <head>
style="color:red">div tag</span> alongwith CSS</p> <title>Emphasized Text Example</title>
</body> </head>
</html> <body>
<p>The following word uses a <em>emphasized</em> typeface.</p>
This will produce the following result:
</body>
This is the example of span tag and the div tag along with CSS
</html>
These tags are commonly used with CSS to allow you to attach a style to a section of a page.
This will produce the following result:

The following word uses an emphasized typeface.

Marked Text
Anything that appears with-in <mark>...</mark> element, is displayed as marked with
yellow ink.

Example
<!DOCTYPE html>
<html>
<head>
<title>Marked Text Example</title>

40 41
HTML HTML

</head> <title>Text Abbreviation</title>


<body> </head>
<p>The following word has been <mark>marked</mark> with yellow</p> <body>
</body> <p>My best friend's name is <abbr title="Abhishek">Abhy</abbr>.</p>
</html> </body>
</html>
This will produce the following result:

The following word has been marked with yellow. This will produce the following result:

My best friend's name is Abhy.


Strong Text
Anything that appears within <strong>...</strong> element is displayed as important text. Acronym Element
The <acronym> element allows you to indicate that the text between <acronym> and
Example </acronym> tags is an acronym.

<!DOCTYPE html> At present, the major browsers do not change the appearance of the content of the
<acronym> element.
<html>
<head> Example
<title>Strong Text Example</title>
<!DOCTYPE html>
</head>
<html>
<body>
<head>
<p>The following word uses a <strong>strong</strong> typeface.</p>
<title>Acronym Example</title>
</body>
</head>
</html>
<body>
This will produce the following result: <p>This chapter covers marking up text in <acronym>XHTML</acronym>.</p>
The following word uses a strong typeface. </body>
</html>
Text Abbreviation
This will produce the following result:
You can abbreviate a text by putting it inside opening <abbr> and closing </abbr> tags. If
present, the title attribute must contain this full description and nothing else.
This chapter covers marking up text in XHTML.
Example
Text Direction
<!DOCTYPE html>
The <bdo>...</bdo> element stands for Bi-Directional Override and it is used to override
<html>
the current text direction.
<head>

42 43
HTML HTML

The following word is a special term.


Example
<!DOCTYPE html>
Quoting Text
<html>
When you want to quote a passage from another source, you should put it in
<head> between<blockquote>...</blockquote> tags.
<title>Text Direction Example</title>
Text inside a <blockquote> element is usually indented from the left and right edges of the
</head> surrounding text, and sometimes uses an italicized font.
<body>
Example
<p>This text will go left to right.</p>
<p><bdo dir="rtl">This text will go right to left.</bdo></p> <!DOCTYPE html>
</body> <html>
</html> <head>
<title>Blockquote Example</title>
This will produce the following result:
</head>
This text will go left to right.
<body>
This text will go right to left.
<p>The following description of XHTML is taken from the W3C Web site:</p>

Special Terms <blockquote>XHTML 1.0 is the W3C's first Recommendation for XHTML, following on
The <dfn>...</dfn> element (or HTML Definition Element) allows you to specify that you from earlier work on HTML 4.01, HTML 4.0, HTML 3.2 and HTML 2.0.</blockquote>
are introducing a special term. It's usage is similar to italic words in the midst of a paragraph. </body>
Typically, you would use the <dfn> element the first time you introduce a key term. Most </html>
recent browsers render the content of a <dfn> element in an italic font.
This will produce the following result:
Example The following description of XHTML is taken from the W3C Web site:
<!DOCTYPE html>
XHTML 1.0 is the W3C's first Recommendation for XHTML, following on from earlier
<html> work on HTML 4.01, HTML 4.0, HTML 3.2 and HTML 2.0.
<head>
<title>Special Terms Example</title>
Short Quotations
</head>
The <q>...</q> element is used when you want to add a double quote within a sentence.
<body>
<p>The following word is a <dfn>special</dfn> term.</p> Example
</body>
<!DOCTYPE html>
</html>
<html>
This will produce the following result: <head>

44 45
HTML HTML

<title>Double Quote Example</title> Example


</head>
<!DOCTYPE html>
<body>
<html>
<p>Amit is in Spain, <q>I think I am wrong</q>.</p>
<head>
</body>
<title>Computer Code Example</title>
</html>
</head>

This will produce the following result: <body>

Amit is in Spain, I think I am wrong. <p>Regular text. <code>This is code.</code> Regular text.</p>
</body>

Text Citations </html>

If you are quoting a text, you can indicate the source placing it between an opening <cite>tag This will produce the following result:
and closing </cite> tag
Regular text. This is code. Regular text.
As you would expect in a print publication, the content of the <cite> element is rendered in
italicized text by default.
Keyboard Text
Example When you are talking about computers, if you want to tell a reader to enter some text, you
can use the <kbd>...</kbd> element to indicate what should be typed in, as in this
<!DOCTYPE html> example.
<html>
<head> Example
<title>Citations Example</title> <!DOCTYPE html>
</head> <html>
<body> <head>
<p>This HTML tutorial is derived from <cite>W3 Standard for HTML</cite>.</p> <title>Keyboard Text Example</title>
</body> </head>
</html> <body>

This will produce the following result: <p>Regular text. <kbd>This is inside kbd element</kbd> Regular text.</p>
</body>
This HTML tutorial is derived from W3 Standard for HTML.
</html>

Computer Code This will produce the following result:

Any programming code to appear on a Web page should be placed Regular text. This is inside kbd element Regular text.
inside <code>...</code>tags. Usually the content of the <code> element is presented in a
monospaced font, just like the code in most programming books.

46 47
HTML HTML

Programming Variables Address Text


This element is usually used in conjunction with the <pre> and <code> elements to indicate The <address>...</address> element is used to contain any address.
that the content of that element is a variable.
Example
Example
<!DOCTYPE html>
<!DOCTYPE html>
<html>
<html>
<head>
<head>
<title>Address Example</title>
<title>Variable Text Example</title>
</head>
</head>
<body>
<body>
<address>388A, Road No 22, Jubilee Hills - Hyderabad</address>
<p><code>document.write("<var>user-name</var>")</code></p>
</body>
</body>
</html>
</html>
This will produce the following result:
This will produce the following result:
388A, Road No 22, Jubilee Hills - Hyderabad
document.write("user-name")

Program Output
The <samp>...</samp> element indicates sample output from a program, and script etc.
Again, it is mainly used when documenting programming or coding concepts.

Example
<!DOCTYPE html>
<html>
<head>
<title>Program Output Example</title>
</head>
<body>
<p>Result produced by the program is <samp>Hello World!</samp></p>
</body>
</html>

This will produce the following result:

Result produced by the program is Hello World!


48 49
7. HTML – META TAGS HTML HTML

Example
Following is an example, where we are adding HTML, Meta Tags, Metadata as important
keywords about the document.

<!DOCTYPE html>
HTML lets you specify metadata - additional important information about a document in a
variety of ways. The META elements can be used to include name/value pairs describing <html>
properties of the HTML document, such as author, expiry date, a list of keywords, document <head>
author etc.
<title>Meta Tags Example</title>
The <meta> tag is used to provide such additional information. This tag is an empty element
<meta name="keywords" content="HTML, Meta Tags, Metadata" />
and so does not have a closing tag but it carries information within its attributes.
</head>
You can include one or more meta tags in your document based on what information you
want to keep in your document but in general, meta tags do not impact physical appearance <body>
of the document so from appearance point of view, it does not matter if you include them or <p>Hello HTML5!</p>
not.
</body>
</html>
Adding Meta Tags to Your Documents
This will produce the following result:
You can add metadata to your web pages by placing <meta> tags inside the header of the
document which is represented by <head> and </head> tags. A meta tag can have
Hello HTML5!
following attributes in addition to core attributes:

Attribute Description
Document Description
Name Name for the property. Can be anything. Examples include, keywords, You can use <meta> tag to give a short description about the document. This again can be
description, author, revised, generator etc. used by various search engines while indexing your webpage for searching purpose.

Example
content Specifies the property's value.
<!DOCTYPE html>
scheme Specifies a scheme to interpret the property's value (as declared in the <html>
content attribute).
<head>
<title>Meta Tags Example</title>
http- Used for http response message headers. For example, http-equiv can be
equiv used to refresh the page or to set a cookie. Values include content-type, <meta name="keywords" content="HTML, Meta Tags, Metadata" />
expires, refresh and set-cookie. <meta name="description" content="Learning about Meta Tags." />
</head>
<body>
Specifying Keywords
<p>Hello HTML5!</p>
You can use <meta> tag to specify important keywords related to the document and later
</body>
these keywords are used by the search engines while indexing your webpage for searching
purpose. </html>

50 51
HTML HTML

Document Revision Date </head>

You can use <meta> tag to give information about when last time the document was updated. <body>
This information can be used by various web browsers while refreshing your webpage. <p>Hello HTML5!</p>
</body>
</html>
Example
<!DOCTYPE html>
Page Redirection
<html>
You can use <meta> tag to redirect your page to any other webpage. You can also specify a
<head>
duration if you want to redirect the page after a certain number of seconds.
<title>Meta Tags Example</title>
<meta name="keywords" content="HTML, Meta Tags, Metadata" /> Example
<meta name="description" content="Learning about Meta Tags." /> Following is an example of redirecting current page to another page after 5 seconds. If you
want to redirect page immediately then do not specify content attribute.
<meta name="revised" content="Tutorialspoint, 3/7/2014" />
</head> <!DOCTYPE html>
<body> <html>
<p>Hello HTML5!</p> <head>
</body> <title>Meta Tags Example</title>
</html> <meta name="keywords" content="HTML, Meta Tags, Metadata" />
<meta name="description" content="Learning about Meta Tags." />

Document Refreshing <meta name="revised" content="Tutorialspoint, 3/7/2014" />


<meta http-equiv="refresh" content="5; url=http://www.tutorialspoint.com" />
A <meta> tag can be used to specify a duration after which your web page will keep refreshing
automatically. </head>
<body>
Example <p>Hello HTML5!</p>
If you want your page keep refreshing after every 5 seconds then use the following syntax.
</body>

<!DOCTYPE html> </html>

<html>
<head> Setting Cookies
<title>Meta Tags Example</title>
Cookies are data, stored in small text files on your computer and it is exchanged between
<meta name="keywords" content="HTML, Meta Tags, Metadata" /> web browser and web server to keep track of various information based on your web
application need.
<meta name="description" content="Learning about Meta Tags." />
<meta name="revised" content="Tutorialspoint, 3/7/2014" /> You can use <meta> tag to store cookies on client side and later this information can be used
by the Web Server to track a site visitor.
<meta http-equiv="refresh" content="5" />

52 53
HTML

Example
Following is an example of redirecting current page to another page after 5 seconds. If you
want to redirect page immediately then do not specify content attribute.

<!DOCTYPE html>
<html>
<head>
<title>Meta Tags Example</title>
<meta name="keywords" content="HTML, Meta Tags, Metadata" />
<meta name="description" content="Learning about Meta Tags." />
<meta name="revised" content="Tutorialspoint, 3/7/2014" />

54

You might also like