Unit 3
Unit 3
Tip: You can use either .htm or .html as file extension. There is no difference, it is up to you.
File path
or URL
Browser
window
BCA I SEM I Subject: Web Page Design
<head>
<title>This is document title</title>
</head>
<body>
<h1>This is a heading</h1>
<p>Document content goes here.....</p>
</body>
</html>
Output:-This is a heading
Document content goes here.....
HTML is a markup language and makes use of various tags to format the content. These
tags are enclosed within angle braces <Tag Name>. Except few tags, most of the tags have
their corresponding closing tags. For example, <html> has its closing tag </html> and
<body> tag has its closing tag </body> tag etc.
Above example of HTML document uses the following tags –
(i) <!DOCTYPE...>
This tag defines the document type and HTML version. Current version of HTML is 5 and
it makes use of the following declaration −
<!DOCTYPE html>
(ii) HTML – After DOCTYPE tag, the HTML tag is written to start the template. All the code
will be placed into this HTML tag. It works as the container for the whole HTML page elements.
BCA I SEM I Subject: Web Page Design
<html>
<!-- Rest of the html code will come inside it -->
</html>
(iii) HEAD – <head> tag is the first element inside the <html> tag. It is used to provide
information to the browser about the page and its contents.Search Engine Optimization (SEO)
techniques are written inside this tag. <title>, <meta> tags are written inside these tag.
<head>
<title>This is document title</title>
</head>
(iv) BODY – <body> tags are written after the closing tag of the <head> tag, i.e. after </head>.
Whatever HTML code is written inside these tags will be shown by the browser as website
content.
<body>
<h1>This is a heading</h1>
<p>Document content goes here.....</p>
</body>
BCA I SEM I Subject: Web Page Design
Ans:-The <p> tag offers a way to structure your text into different paragraphs. Each paragraph
of text should go in between an opening <p> and a closing </p> tag as shown below in the
example −
Example:
<!DOCTYPE html>
<html>
<head>
<title>Paragraph Example</title>
</head>
<body>
<p>Here is a first paragraph of text.</p>
<p>Here is a second paragraph of text.</p>
<p>Here is a third paragraph of text.</p>
</body>
</html>
-An attribute is used to define the characteristics of an HTML element and is placed inside the
element's opening tag. All attributes are made up of two parts − a name and a value
The name is the property you want to set. For example, the paragraph <p> element in the
example carries an attribute whose name is align, which you can use to indicate the
alignment of paragraph on the page.
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, center
and right.
BCA I SEM I Subject: Web Page Design
Example:
<html>
<head>
<title>Align Attribute Example</title>
</head>
<body>
<palign="left">This is left aligned</p>
<palign="center">This is center aligned</p>
<palign="right">This is right aligned</p>
</body>
</html>
Ans:- 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 in HTML. Formatting elements were designed to display special types of text. The
HTML formatting tags are as follows:
ii. Strong: The HTML <strong> element defines text with strong importance. The
content inside is typically displayed in bold.
Example: <strong>This text is important!</strong>
Output: This text is important!
iii. Italic: Anything that appears within <i>...</i> element is displayed in italicized
Example: <i>italicized</i>
Output: italicized
iv. Underlined Text: Anything that appears within <u>...</u> element, is displayed with
underline.
Example: <u>underlined</u>
Output: underlined
of different widths (for example, the letter 'm' is wider than the letter 'i'). In a
monospaced font, however, each letter has the same width.
viii. 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.
Example: <p>The following word uses a <sub>subscript</sub> typeface.</p>
Output: The following word uses a subscript typeface.
BCA I SEM I Subject: Web Page Design
</html>
This will produce the following result without displaying the content given as a part of
comments –
Document content goes here.....
BCA I SEM I Subject: Web Page Design
Ans:-Any document starts with a heading. You can use different sizes for your headings. HTML
also 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
heading.
Example:
<!DOCTYPE html>
<html>
<head>
<title>Heading Example</title>
</head>
<body>
<h1>This is heading 1</h1>
<h2>This is heading 2</h2>
<h3>This is heading 3</h3>
<h4>This is heading 4</h4>
<h5>This is heading 5</h5>
<h6>This is heading 6</h6>
</body>
</html>
This is heading 1
This is heading 2
This is heading 3
This is heading 4
This is heading 5
This is heading 6
InHTML <h1> to <h6> align Attribute is used to specify the alignment of the <h> element or
the content present inside the Heading Element.
Syntax:
<h1 align="left | right | center | justify">
<br> line break and horizontal rule with syntax and example.
The <br> tag inserts a single line break. The <br> tag is useful for writing addresses or poems.
The <br> tag is an empty tag which means that it has no end tag. Use the <br> tag to enter line
breaks, not to add space between paragraphs.
Syntax: <br>
Attributes in <HR> Tag:- The HTML <hr> tag is used for creating a horizontal line. This is also
called Horizontal Rule in HTML.
Attribute Value Description
Output:-
BCA I SEM I Subject: Web Page Design
Program:
<!DOCTYPE html>
<html>
<head>
<title>hr tag with attributes</title>
BCA I SEM I Subject: Web Page Design
</head>
<body>
<p>Normal horizontal line.</p>
<hr>
<p>Colour horizontal line.</p>
<hrcolor="red">
<p>Horizontal line with height of 30 pixels</p>
<hr size="30">
<p>Horizontal line with height of 30 pixels And noshade.</p>
<hr size="30" noshade>
<p>Horizontal line with height and colour shade.</p>
<hr size="30" color="fuschia">
</body>
</html>
Output:-