SlideShare a Scribd company logo
HTML <div> Tag
Dr.T.Abirami
Associate Professor
Department of IT
Kongu Engineering College
Perundurai
HTML <div> Tag
• The <div> tag defines a division or a section in an HTML document.
• The <div> tag is used as a container for HTML elements
• The <div> tag is easily styled by using the class or id attribute.
• Any sort of content can be put inside the <div> tag!
• Note: By default, browsers always place a line break before and after the
<div> element.
<html>
<head>
<style>
div { color: white; background-color: 009900; margin: 2px; font-size: 25px; } </style>
</head>
<body>
<div id="1">
<p> Welcome </p>
</div>
<div id="2">
<p> Welcome kongu </p>
</div>
</body>
</html>
<html>
<head>
<title>The div Tag</title>
</head>
<body>
<h1> The div Tag </h1>
<div style="background-color:#8ebf42">
<p>We use the tag to group two paragraphs for applying a background to
the text, and to add color to this
</p>
</div>
</body>
</html>
<html>
<head>
<link href="samplecss.css" rel="stylesheet">
</head>
<body>
<div class="aa">
<p> Welcome </p>
</div>
<div class="bb">
<p> Welcome kongu </p>
</div>
</body>
</html>
.aa {color: blue;
background-color: 009900;
margin: 2px;
font-size: 25px; }
.bb {color: white;
background-color: 009900;
margin: 2px;
font-size: 30px; }
samplecss.css

More Related Content

div tag.pdf

  • 1. HTML <div> Tag Dr.T.Abirami Associate Professor Department of IT Kongu Engineering College Perundurai
  • 2. HTML <div> Tag • The <div> tag defines a division or a section in an HTML document. • The <div> tag is used as a container for HTML elements • The <div> tag is easily styled by using the class or id attribute. • Any sort of content can be put inside the <div> tag! • Note: By default, browsers always place a line break before and after the <div> element.
  • 3. <html> <head> <style> div { color: white; background-color: 009900; margin: 2px; font-size: 25px; } </style> </head> <body> <div id="1"> <p> Welcome </p> </div> <div id="2"> <p> Welcome kongu </p> </div> </body> </html>
  • 4. <html> <head> <title>The div Tag</title> </head> <body> <h1> The div Tag </h1> <div style="background-color:#8ebf42"> <p>We use the tag to group two paragraphs for applying a background to the text, and to add color to this </p> </div> </body> </html>
  • 5. <html> <head> <link href="samplecss.css" rel="stylesheet"> </head> <body> <div class="aa"> <p> Welcome </p> </div> <div class="bb"> <p> Welcome kongu </p> </div> </body> </html> .aa {color: blue; background-color: 009900; margin: 2px; font-size: 25px; } .bb {color: white; background-color: 009900; margin: 2px; font-size: 30px; } samplecss.css