UNIT4 HTML
UNIT4 HTML
</head>
<body>
JYOTI VERMA 1
UNIT-4: HTML & STRUCTURE WEB PAGE
</body>
</html>
HTML Comments
Comments are piece of code which is ignored by any web browser.
HTML Comment lines are indicated by the special beginning tag <!-- and ending
tag --> placed at the beginning and end of EVERY line to be treated as a comment.
This tag can be used for both single and multi line comment.
Example single line comment:
<!-- comment line -->
Example multi line comment:
<!-- line1 is commented
line2 is commented
line3 is commented
-->
Using Comment tag
There are few browsers who supports <comment> tag to comment a part of code.
Example : <p>This is <comment>not</comment> Internet Explorer.</p>
HTML Attributes (alt, href, src, width, height, style, title, id)
HTML Attributes
All HTML elements can have attributes
Attributes provide additional information about elements
Attributes are always specified in the start tag
Attributes usually come in name/value pairs like: name="value"
Id attribute
The id attribute specifies a unique id for an HTML element (the value must be
unique within the HTML document).
The id attribute is most used to point to a style in a style sheet, and by JavaScript
(via the HTML DOM) to manipulate the element with the specific id.
Syntax
<element id="id">
JYOTI VERMA 2
UNIT-4: HTML & STRUCTURE WEB PAGE
Example
<h2><a id="top">Someheading</a></h2>
</html>
<html>
<head>
<title>
</body>
</html>
Paragraph <p>
You can divide the text in your web page into paragraphs.
The <p> tag is used for this purpose.
The syntax:
<p> content </p>
Each line specified with the <p> tag will begin on new line and a blank line will be
inserted by the browser in between paragraphs
Example:
<html>
<head>
<title>
Paragraph Example..........
</title>
</head>
<body>
<p>An eagle was sitting on a tree resting,
doing nothing. </p>
<p>A small rabbit saw the eagle and asked him, </p>
<p>"Can I also sit like you and do nothing?"</p>
</body>
</html>
JYOTI VERMA 4
UNIT-4: HTML & STRUCTURE WEB PAGE
</head>
<body>
<p align="center">An eagle was sitting on a tree resting, doing nothing. </p>
<p align="left">A small rabbit saw the eagle and asked him, "Can I also sit like
you and do nothing?"</p>
<p align="justify">The eagle answered, "Sure , why not."
So the rabbit sat on the ground below the eagle and rested.
All of a sudden, a fox appeared, jumped on the rabbit and ate it. </p>
<p align="right">Moral of the story: To be sitting and doing nothing, you must be
sitting very, very high up.</p>
</body>
</html>
The title Attribute
The title attribute defines some extra information about an element.
The value of the title attribute will be displayed as a tooltip when you mouse over
the element:
Example
JYOTI VERMA 5
UNIT-4: HTML & STRUCTURE WEB PAGE
<Br> tag
New line can be inserted without creating paragraph using <br> or <br/> tag
Example
<html>
<head>
<title>
New line example...........
</title>
</head>
<body>
An eagle was sitting on a tree resting, doing nothing. <br>A small rabbit saw
the eagle and asked him, "Can I also sit like you and do nothing?"
The eagle answered, "Sure , why not."<br>So the rabbit sat on the ground below the
eagle and rested.All of a sudden, a fox appeared, jumped on the rabbit and ate it.
<br>Moral of the story: To be sitting and doing nothing, you must be sitting very,
very high up.
</body>
</html>
<a> tag
Different pages of a website can be connected with one another through links
known as hyperlinks.
Links can take you directly to other pages and even specific parts of a given page
A link is specified using the <a> element called anchor tag.
Anything between the opening <a> tag and the closing </a> tag becomes part of
the link and a user can click that part to reach to the linked document.
It contains at least one attribute. For the function of linking to a different
document.
Most browsers display linked text as blue and underlined, and linked images with
a blue border.
JYOTI VERMA 6
UNIT-4: HTML & STRUCTURE WEB PAGE
Visited links generally display in purple. Users can change these colors in their
browser preferences, and, of course, you can change the appearance of links for
your sites using style sheets
</head>
<body >
<a href="p1.html"
target="_blank" >first page</a> |
<a href="p2.html"
target="_self" >Second page</a> |
<a href="p3.html"
target="_top" >third page</a>
</body>
</html>
<img> tag
You can insert any image in your web page by using <img> tag.
It is an empty element, which means it doesn’t have any content.
It is an inline element, so it behaves like any other inline element in the text flow
Syntax:
<img src="image URL“ alt=“text” />
JYOTI VERMA 7
UNIT-4: HTML & STRUCTURE WEB PAGE
Example
JYOTI VERMA 8
UNIT-4: HTML & STRUCTURE WEB PAGE
Code:
<html>
<body>
<p> <b>Here is some text in bold. </b></p>
</body>
</html>
The <strong> tag, on the other hand, is considered as a logical tag, and it is used to
inform the browser that the text in the tag has some logical importance.
Example
<html>
<body>
<p> <strong>This is an important content formatted using the strong tag </strong>,
and this is just
normally formatted text</p>
</body>
</html>
Setting Text as Italic
Just as setting text as Bold, you can use <i> tag and <em> tag to set text as italic
Using <i> is for, just like using <b>, physical display of text as italic and the tag <em>
while also showing the text as italic on display, lets the browser know that it has
semantic importance.
Example
<html>
<body>
<p> <i> This is the first para in italic text. </i></p>
<p> <em> This content is made italics with the em tag</em>, This is normal text </p>
</body>
</html>
Highlighting Text
If you want to highlight some text with a highlighter effect, the tag <mark> can be
used; with default CSS, the tag makes the background of text as yellow, helping you
grab a visitor’s attention on that text easily.
Example
<html>
JYOTI VERMA 9
UNIT-4: HTML & STRUCTURE WEB PAGE
<body>
<h3> This text uses <mark> Mark</mark> tag to highlight text on the page </h3>
</body>
</html>
Underlining Text in HTML
The HTML tag <u> can be used to add an underline in the text. Be careful not to use
underlining with blue text as it may confuse visitors that the text is a link.
Example
<html>
<body>
<p> <u> This is Text with underline tag. </u> </p>
</body>
</html>
JYOTI VERMA 10
UNIT-4: HTML & STRUCTURE WEB PAGE
Deleted Text
<del> tag is used as a logical way of telling the browser that text inside the text is
deleted. Keep in mind that to a user, the shown text is the same as the tag in
strikethrough tag, meaning it is shown in strikethrough formatting.
Example
<html>
<body>
<p> This is normal text <del> This is text between del tag. </del> </p>
</body>
</html>
JYOTI VERMA 11
UNIT-4: HTML & STRUCTURE WEB PAGE
In cases where you need some text in a larger size on the screen, but you don’t want
to use a heading or increase the font size with a tag, use <big> content between this
tag will be displayed in noticeably larger text size.
Example
<html>
<body>
<p> This is Normal text <big> This text in in larger size. </big> </p>
</body>
</html>
JYOTI VERMA 12