Sunday, July 15, 2012

HTML basics

 A HTML document has elements. Elements have attributes. Attributes have values. For example,The elements of basic HTML document is

<html>
<head>
<title> … </title>

</head>
<body>

</body>
</html>


Note that, elements (e.g. html)have start tag (e.g. <html>) and closing tag (</html>). Start tag are surrounded by < > (e.g. <html>) and end tag is surrounded by </ > (</html>).

 <html>...</html>  All codes of HTML document are written inside this element.
Attributes: none
 
<head>...</head>  The codes which are written for a website, but not needed to show on page are written here. It must contain title element at the first position.
Attributes: none
 
<title> … </title>  Title of website are written here. It is shown on the top of the browser.

Attributes: none

<body>...</body> Contents of a website are written inside this element. It has three attributes
Attributes: background, bgcolor, text.

For example, write the following code on your notepad
<html>
<head>
<title>first website</title>
</head>
<body>
This is a website
</body>
</html>


Save it as "firstwebsite.html"

View "firstwebsite.html" in a browser. You shall see



You can add attibutes to body element for change. For example to change background color, you can add bgcolor attribute to body element. You can do this by following code
<html>
<head>
<title>first website</title>
</head>
<body bgcolor="green">
This is a website
</body>
</html>


Here, "green" is value of attribute bgcolor. You shall see on browser 


You can add background picture by using following attribute to body element.


<html>
<head>
<title>first website</title>
</head>
<body background ="tulips.jpg">
This is a website
</body>
</html>



Suppose, you have saved "firstwebsite.html" to "project" folder. You have to keep the "tulips.jpg" file on the same folder meaning "project". If you save it in a sub folder "image", you have set link as 

<body background ="images\tulips.jpg">

 




No comments:

Post a Comment