Export to GitHub

doctype-mirror - DivWidthAttribute.wiki


You are here: Home > HTML Reference > Elements > <div> element > width attribute

Usage

```

This is a test of the emergency broadcasting system. If this had been a real emergency, there would probably be a lot more running and screaming.

```

The width attribute is deprecated in favor of the width CSS property, but browsers still support it.

Values

The width attribute specifies the width in pixels, and as such it must be a positive integer, or 0. Unlike widths in CSS, this attribute must NOT include the "px" unit of measure. The width attribute is always understood in pixels.

Elements

You can use the width attribute on the following elements:

  • <address>
  • <applet>
  • <blockquote>
  • <caption>
  • <canvas>
  • <center>
  • <col>
  • <colgroup>
  • <dd>
  • <dir>
  • <div>
  • <dl>
  • <dt>
  • <embed>
  • <fieldset>
  • <form>
  • <frame>
  • <frameset>
  • <hr>
  • <iframe>
  • <ilayer>
  • <img>
  • <isindex>
  • <layer>
  • <li>
  • <listing>
  • <marquee>
  • <menu>
  • <multicol>
  • <object>
  • <ol>
  • <p>
  • <pre>
  • <select>
  • <spacer>
  • <table>
  • <td>
  • <th>
  • <textarea>
  • <ul>

Browser compatibility

Compatibility table legend

| Test | IE8 | IE7 | IE6 | FF3 | FF2 | Saf3 | Op9 | Chrome | |:---------|:--------|:--------|:--------|:--------|:--------|:---------|:--------|:-----------| | div.width reflects <div width="7"> | Y | Y | Y | N | N | N | Y | N |

Further reading