HTML and It's Properties
HTML and It's Properties
2. A web browser is used to display or view the HTML file. Some commonly
used web browsers are internet explorer, google chrome, Mozilla Firefox,
and so on
Creating HTML Documents
1. Open notepad by clicking on search bar > type notepad > click on notepad . The notepad window appear
2. type the following HTML code in the note pad window (fig. 1.1)
3. Click on file > save as. The save as dialog box opens. Enter the name of the file and enclose with .htm or .html
Extension with it for example, first.html (fig. 1.2) click on save button
Tag
A tag is the basic formatting tool of HTML. It is used to tell a web browser how and where a particular text is
to be displayed in a web page.
A tag name is always written between the angle brackets’<‘ and ‘>’. Some examples of HTML tags are
<tittle>,<hr> and <b>.
A tag starts with an ON tag or opening tag, for example <body>, and ends with OFF tag or closing tag, i.e. the
tag name repeated with a ‘/” (forward slash) sign, for example </body>.
Classification of tags
An html tag can be either an empty tag or a container tag
Empty tags: the tags which do not requires an OFF tag are called empty tags. It is not necessary to close
these tags. For example <br> tag which is used to give a line break.
Container tags: the tags which have both, the ON and OFF tags are called container tags. These tags are
necessary to be closed. For example <u> hello world </u>. This tag will not work if it is not closed.
HTML Tags, elements and Attributes
Elements
An element is the basic building block of HTML. It includes everything starting from the opening till the closing
Tag . For example <u> how are you ?</u> is an HTML element. Tags just mark the beginning and end of an HTML element
Attributes
Attributes are extra bits of information related to a tag. Attributes appear inside the opening tag or the on tag
And their values are written inside the quotation marks.
Syntax:
<tag_name attribute_name=“attribute_value”>
For example, <p align =“center”> in this example, ‘align’ is an attribute of <p> tag. It indicates that the text inside the <p>
tag is to be displayed in the center of the browser window.
Rules for writing HTML code
There are some points which you should keep in mind while creating an HTML document.
Tags should remain in the proper tag order.
HTML elements can be nested. For example, <b><i>hello</i></b> will make the word
hello appear bold as well as italicized. A tag which opened first should be closed in the
end.
Always close the tags. A tag which is opened should be closed to avoid confusion.
Prefer lower case characters. However, tags and attributes are not case sensitive but still it
is a good practice to use lower case characters while writing the code.
Always quote attribute values, because unquoted values may create problem while
displaying result
Tag names cannot contain spaces. For example, < H T M L > will not work properly.
Even this type of spacing < HTML > will create a problem while executing.
HTML document structure
An HTML document is always enclosed within <html> and </html> tags. Every HTML
document is divided into two sections head and body.
The head section contains the information about the web page such as document's title.
The body section contains the actual content which is to be displayed in the web page.
The structure of the HTML document is discussed here:
Fig. 1.5
HTML document structure
<!doctype html>: The doctype declaration is used to tell the web browser that the
document being visited is an html document. This statement need not be closed.
<html>: This tag tells the browser that the document is a HTML document. It marks the
beginning and end of the document.
<head>: This is a container tag for all the information related to the web page,
for example, the title, scripts, style, and so on.
<title>: The title to be displayed in the title bar of the web page is enclosed within the
<title> and </title> tag. This is a container tag.
<body>: This tag includes all the information that you want to be displayed on the web
page like text, graphics, videos, and so on. This is also a container tag.
HEADING, PARAGRAPH AND LINE BREAK ELEMENTS
Heading Tags (<hn> ... </hn>)
The <hn> tag helps in defining the different levels of headings in a web page. In the <hn>
tag, n varies from 1 to 6.
For example,
<h1> Heading Level 1 </h1>,
<h2> Heading Level 2 </h2>, and so on.
The tag <h1> is used to define the largest heading, and the tag <h6> is used to define the
smallest heading.
Background-color Used to change the background color of an Color name, color code Background-color: red;
element
Background-size Used to specify the size of the background Auto, width in percent, height Background-size: auto;
image in percent Background-size:20% 10%
Background-image Used to specify the image to be used in the URL(image URL) Background-image:url(tree.jpg);
background of the element mentioned
Background-repeat Used to control the repetition of an image in Repeat, repeat-x(to repeat background-repeat: repeat-y;
the background of the element ,i.e. repeating horizontally), background-repeat: repeat-x;
horizontally, vertically or no repition at all Repeat-y(to vertically),no- background-repeat: no-repeat;
repeat
Background-attachment Used to decide whether the background will Scroll, fixed Background-attachment: scroll;
be scrolling or fixed Background-attachment: fixed;
Background-position Decides the starting position of the image Left ,right ,center ,left top ,left Background-position: left top;
used as background center ,left bottom, right top,
right center, right bottom ,
center top, center center,
center bottom, x% y%