By using this site you agree to the use of cookies.

Learn more

Share via:

div - HTML Element

The div element is used when no other element is appropriate, and for presentational purposes.

Edited: 2017-03-12 14:53

The HTML div element has no special meaning, and is commonly used when no other element is suitable – typically for design purposes.

Before you choose to use div, make sure that no other appropriate element fits in your situation. For example, for text you would normally want to use the p (paragraph) element. Also, instead of using divs for headers and footers, consider using the relevant elements. There are also elements for sectioning and navigation, and using them will make your site more accessible. divs can still be used as a fall-back for ancient browsers.

An example of how divs may be used is shown below:

<div id="header">
  <header>Header content goes here..</header>

Since all modern browsers support the header element, using a fallback div like above, should not be necessary. Divs can also be used for trivial design purposes, such as adding borders, or creating columns in a layout (each column wrapped in a div).

A basic layout example, which is using divs, is included below:

<!DOCTYPE html>
<html lang="en">

   <title>Div Usage Example</title>
   <style type="text/css">
    #WidthControl {
    #columnA {float:right;width:25%}
    #columnB {float:left;width:70%;}

    <div id="WidthControl">

     <div id="columnA">

     <div id="columnB">
       <h1>Main Content</h1>
       <p>Main content goes here...</p>




AttributesOther AttributesGlobal, I18n, Event


  1. div - HTML Standard -