programminghead Logo

HTML Tutorial 8

Div Tag in HTML :

Div tag provides a Division or a Selection in an HTML Document and Div Tag often used as a Container for HTML Elements like Headline,Images,Paragraphs and Many More.

Div Tag Syntax:

Like other HTML tag Div tag also have 2 <div> starting and </div> closing tags and we have to write or Declare this Div tag inside Body tag.

Div Tag Syntax :


    <div> .... </div>

Styling HTML Div :

After using div's Syntax you'll left with empty output. Because the default color of div Element is White, div has 0 border thickness,no height and width. To make DIV Element appear on the Output screen we have to gave a different color and other data like border thickness, Height and width to our Div Element. For that we are going to use CSS.

Div Tag Style :


<html>
 <head>
  <title>HTML DIV tag</title>
  <style type="text/css">
   div{
  	height: 100px;
  	width: 100px;
  	background-color: red;
  	border: 1px solid black; 
      }
  </style>
 </head>
 <body>
  <div></div>
 </body>
</html>

Results

HTML Texts inside Div Tag :

To display HTML Texts like Headlines,Paragraphs and other Normal texts under Div tag we have to Write/Declare those Data between the starting and closing tag of Div tag's

Texts inside Div Tag:


<html>
 <head>
  <title>HTML DIV tag</title>
  <style type="text/css">
   div{
       padding: 10px;
       background-color: blue;
      }
  </style>
 </head>
 <body>
  <div>
   <h2>What is Div</h2>
   <p>Div is a Tag in HTML <br/>
   which is used as a Division or Partition for HTML Data</p>
  </div>
 </body>
</html>

Results

What is Div

Div is a Tag in HTML
which is used as a Division or Partition for HTML Data

Image inside Div Tag :

To display Image under Div tag we have to Write/Declare That Image between the starting and closing tag of Div tag's

Image inside Div Tag:


<html>
 <head>
  <title>HTML DIV tag</title>
  <style type="text/css">
   div{
       padding: 10px;
       background-color: blue;
       text-align:center;
      }
  </style>
 </head>
 <body>
  <img src="http://programminghead.com/images/cat.jpg"/>
 </body>
</html>

Results

Table inside Div Tag :

To display Table under Div tag we have to Write/Declare That Table between the starting and closing tag of Div tag's

Table inside Div Tag:


<html>
 <head>
  <title>HTML DIV tag</title>
  <style type="text/css">
   div{
      background-color: blue;
      padding: 4px;
      }  
   table,th,td{
       padding: 4px;
       border-collapse: collapse;
      }
  </style>
 </head>
 <body>
	<div>
	  <table> 
	      <tr>
	        <th>S No.</th>
	        <th>Name</th>
	        <th>Age</th>
	      </tr>

	      <tr>
	        <td>1</td>
	        <td>John</td>
	        <td>22</td>
	      </tr>

	      <tr>
	        <td>2</td>
	        <td>Jack</td>
	        <td>21</td>
	      </tr>	      
	    </table>
    </div>				
 </body>
</html>

Results

S No. Name Age
1 John 22
2 Jack 21
Comments

download minecraft free

http://forum.muhanoi1.com/member.php?u=161242-ChuSheean
01:38 pm

I know this if off topic but I'm looking into starting my own weblog and was wondering what all is required to get set up? I'm assuming having a blog like yours would cost a pretty penny? I'm not very internet smart so I'm not 100% certain. Any recommendations or advice would be greatly appreciated. Appreciate it

free minecraft download

http://tinyurl.com/yyfbfwcj
11:47 pm

I think this is among the most important info for me. And i am glad reading your article. But should remark on few general things, The web site style is perfect, the articles is really great : D. Good job, cheers

mojang minecraft download

http://tinyurl.com/yy9dlxhc
03:55 am

I was extremely pleased to discover this site. I need to to thank you for ones time for this particularly wonderful read!! I definitely savored every bit of it and i also have you saved to fav to look at new information on your blog.

minecraft for free

http://tinyurl.com/yxa2dvnq
05:50 pm

I'm extremely pleased to find this website. I want to to thank you for your time just for this fantastic read!! I definitely enjoyed every part of it and I have you saved to fav to see new stuff in your website.

g

http://bit.ly/2WyDujO
09:37 pm

Thanks for finally writing about >HTML Div Tag - What is Div in HTML And Div tag's uses

g

http://tinyurl.com/yyhedr63
10:44 am

It's truly very complicated in this active life to listen news on Television, therefore I simply use web for that reason, and take the newest news.

g

http://bit.ly/2JvwNv7
12:43 am

Great article.

free minecraft download

http://tinyurl.com/y6ytzwqy
06:53 am

I used to be able to find good advice from your blog articles.

how to download minecraft

http://j.mp/2vHEVkk
03:58 pm

I'd like to thank you for the efforts you have put in writing this blog. I really hope to see the same high-grade blog posts by you later on as well. In fact, your creative writing abilities has encouraged me to get my very own site now ;)

minecraft download free

http://tinyurl.com/y49jj9z3
12:20 pm

I have been browsing on-line more than 3 hours lately, but I by no means discovered any fascinating article like yours. It's beautiful price sufficient for me. In my opinion, if all site owners and bloggers made good content material as you probably did, the internet will probably be a lot more useful than ever before.

download minecraft free

http://bit.ly/2WnX5TW
11:45 am

Hi there, I enjoy reading through your article. I wanted to write a little comment to support you.

how to download minecraft free

http://bit.ly/2vHEVkk
06:02 pm

These are truly impressive ideas in regarding blogging. You have touched some pleasant things here. Any way keep up wrinting.

gamefly free trial

http://tinyurl.com/yxehxkvv
03:10 am

It's very easy to find out any topic on net as compared to textbooks, as I found this article at this web page.

gamefly

http://tinyurl.com/y6h3yeeq
12:33 pm

I every time spent my half an hour to read this webpage's posts every day along with a cup of coffee.

gamefly free trial

http://bit.ly/2XUuMwH
01:38 pm

It is perfect time to make some plans for the long run and it is time to be happy. I've read this submit and if I may I wish to counsel you some fascinating issues or tips. Perhaps you could write next articles regarding this article. I desire to read more things approximately it!

Write to Us