
- HTML Tutorial
- HTML - Home
- HTML - Overview
- HTML - Basic Tags
- HTML - Elements
- HTML - Attributes
- HTML - Formatting
- HTML - Phrase Tags
- HTML - Meta Tags
- HTML - Comments
- HTML - Images
- HTML - Tables
- HTML - Lists
- HTML - Text Links
- HTML - Image Links
- HTML - Email Links
- HTML - Frames
- HTML - Iframes
- HTML - Blocks
- HTML - Backgrounds
- HTML - Colors
- HTML - Fonts
- HTML - Forms
- HTML - Embed Multimedia
- HTML - Marquees
- HTML - Header
- HTML - Style Sheet
- HTML - Javascript
- HTML - Layouts
- HTML References
- HTML - Tags Reference
- HTML - Attributes Reference
- HTML - Events Reference
- HTML - Fonts Reference
- HTML - ASCII Codes
- ASCII Table Lookup
- HTML - Color Names
- HTML - Entities
- HTML - Fonts Ref
- HTML - Events Ref
- MIME Media Types
- HTML - URL Encoding
- Language ISO Codes
- HTML - Character Encodings
- HTML - Deprecated Tags
- HTML Resources
- HTML - Quick Guide
- HTML - Useful Resources
- HTML - Color Code Builder
- HTML - Online Editor
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
HTML - div Tag
Description
The HTML <div> tag is used for defining a section of your document. With the div tag, you can group large sections of HTML elements together and format them with CSS.
The difference between the div tag and the span tag is that the div tag is used with blocklevel elements whilst the span tag is used with inline elements.
Example
<!DOCTYPE html> <html> <head> <title>HTML div Tag</title> <link rel = "stylesheet" href = "style2.css"> </head> <body> <div id = "contentinfo"> <p>Welcome to our website. We provide tutorials on various subjects.</p> </div> </body> </html>
Here is the csss file style2.css
#contentinfo p { line-height: 20px; margin: 30px; padding-bottom: 20px; text-align: justify; width: 140px; color: red; }
This will produce the following result −
Global Attributes
This tag supports all the global attributes described in HTML Attribute Reference
Specific Attributes
The HTML <div> tag also supports the following additional attributes −
Attribute | Value | Description |
---|---|---|
autofocus ![]() |
autofocus | Specifies |
Event Attributes
This tag supports all the event attributes described in HTML Events Reference
Browser Support
Chrome | Firefox | IE | Opera | Safari | Android |
---|---|---|---|---|---|
Yes | Yes | Yes | Yes | Yes | Yes |
html_tags_reference.htm
Advertisements