Tuesday, November 20, 2012

Div and span

Div:
Div <div> tag is that it divides the HTML document into sections. Proper usage of the <div> tag is fundamental to good HTML coding, the <div> tag is one of the most powerful tools available to a web developer.

Span:
Span <span> is  in-line level elements, they only span across small amounts of content, typically words or phrases.
For example:
a <span> tag might be used to make a word red in color or to give it an underline.



Div Elements
The <div> tag is nothing more than a container for other tags. Much like the body tag Div elements are block elements and work behind the scenes grouping other tags together. Use only following attributes with your div element, anything else should be reserved for css.
  • id
  • width
  • height
  • title
  • style

Try out example:
Example of div
<html>
<head>
<style>
#container {
margin:0px auto;
background-color:black;
width:500px;
color:white;
}
</style>
</head>
<body>
<div id=”container”>
I love my country Nepal.
</div>
</body>
</html>


Example of span
<html>
<head>
<style>
.text {
font-size:24px;
color:white;
}
</style>
</head>
<body>
<div id=”container”>
I love my country Nepal.
</div>
</body>
</html>

No comments:

Post a Comment