Easy To Learning
  • Login
  • Sign Up
  • Q&A
  • Home
  • Php Tutorial
  • MySql Tutorial
  • Object-Oriented Programming
  • Java Tutorial
  • HTML Tutorial
  • React JS Tutorials
  • Free Projects
  • Blogs & Articles
  • Others
    • About Us
    • Contact Us
HTML Div Tag
Easy To Learning

Education Needs Complete Solution

Online Ask Question Question And Answer
  1. Home
  2. HTML Tutorials
  3. HTML Div Tag

HTML Tutorial

Basic HTML Fundamentals

  • HTML Table Content
  • Introduction To HTML
  • What Is HTML
  • HTML Tags
  • HTML Formatting
  • HTML Heading
  • HTML Paragraph
  • HTML Anchor
  • HTML Image
  • HTML Table
  • HTML Lists
  • HTML Ordered List
  • HTML Unordered List
  • HTML Description List
  • HTML Form

HTML Tags

  • Marquee HTML
  • HTML Textarea
  • HTML Quotes
  • HTML Style
  • HTML Title Or HTML Doctype
  • HTML Div Tag
  • HTML Pre Tag
  • HTML Code Tag
  • HTML Label Tag
  • HTML Input Tag
  • HTML Button Tag
  • HTML Hr Tag
  • HTML Br Tag
  • HTML Script Tag
  • HTML NoScript Tag
  • HTML Bold Tag

HTML Div Tag

HTML Div Tag

The HTML <div> tag is used to group the large section of HTML elements together.

We know that every tag has a specific purpose e.g. p tag is used to specify paragraph, <h1> to <h6> tag are used to specify headings but the <div> tag is just like a container unit which is used to encapsulate other page elements and divides the HTML documents into sections.

The div tag is generally used by web developers to group HTML elements together and apply CSS styles to many elements at once. For example: If you wrap a set of paragraph elements into a div element so you can take the advantage of CSS styles and apply font style to all paragraphs at once instead of coding the same style for each paragraph element.

Div Tag Usage

  • The <div> tag defines a division or a section in an HTML document.
  • The <div> tag is used to group block-elements to format them with CSS.
<div style="border:1px solid red;padding:20px;font-size:20px">  
<p>PHP Tutorial, Java Tutorial, Android Tutorial, Spring Tutorial, MySql Tutorial etc learning tutorial website.</p>  
<p>This is second paragraph</p>  
</div>  

Output

PHP Tutorial, Java Tutorial, Android Tutorial, Spring Tutorial, MySql Tutorial etc learning tutorial website.

This is second paragraph

Difference between HTML div tag and span tag

div tag span tag
HTML div is a block element. HTML span is an inline element
HTML div element is used to wrap large sections of elements. HTML span element is used to wrap small portion of texts, image etc.

HTML div example: Registration Form

In this example, we are creating box using div tag. There is a registration form inside the box. Let's see the CSS and HTML code.

CSS Code:

.registrationform{  
    padding:10px;  
    border:1px solid red;  
    border-radius:10px;  
    float:right;  
    margin-top:10px;  
}  
.formheading{  
    background-color:black;  
    color:white;  
    padding:4px;  
    text-align:center;  
}  
.sub{  
background-color:blue;  
padding: 7px 40px 7px 40px;  
color:white;  
font-weight:bold;  
margin-left:70px;  
border-radius:5px;  
}  

HTML Code:

<div class="registrationform">  
<h3 class="formheading">Please Register</h3>  
<form action="register.php" method="post">  
<table>  
<tr><td>Name:</td><td><input type="text" name="name"/></td></tr> 
<tr><td>Email:</td><td><input type="email" name="email"/></td></tr>  
<tr><td>Password:</td><td><input type="password" name="password"/></td></tr>
<tr><td>Confirm Password:</td><td><input type="password" name="cpassword"/></td></tr>  
<tr><td colspan="2" style="text-align:center"><input class="sub" type="submit" value="register"/></td></tr>  
</table>  
</form>  
</div>  

Output

  

Please Register  

Name:
Email:
Password:
Confirm Password:

 

 

 
Series: HTML Tutorials Hub
All Topics
Free Download Projects
Previous Chapter
Next Chapter

Ask a Question

Have a coding query or doubt? Ask here and get help from our community.

500 characters remaining
Submitting...
Free Download Projects
Join Telegram Group Join WhatsApp Group
Related Topics:
how to use div tag in html to divide the page span tag in html html div class html div id div class container html div width html div style class in html

Member Sign In

Forgot?
Signing in...

Don't have an account? Register here

Create Free Account

Register Captcha
Registering...

Already have an account? Sign In

Ask a Question

500 characters remaining
Submitting...

About Easy To Learning

Easy To Learning is a comprehensive programming learning portal offering free, practical, developer-driven tutorials for PHP, Java, Python, Spring, MySQL, CSS, Bootstrap, CakePHP, and more.

Explore community-contributed questions and answers, and download ready-to-run source code projects.

Quick Links

  • Home
  • Questions & Answers
  • Download Projects
  • Blog & Articles
  • Member Login

Community

  • Telegram Group
  • WhatsApp Community
  • Ask a Question
  • Join as Member

Connect With Us

Stay updated with our newest programming tutorials and free open source projects.

© 2026 Easy To Learning. All Rights Reserved.