How to set a border for an HTML div tag

RKh picture RKh · Jan 7, 2010 · Viewed 652.5k times · Source

I am trying to define a border around a div tag in HTML. In some browsers the border does not appear.

Here is my HTML code:

How do I set a border for an HTML div tag?

Answer

Paolo picture Paolo · Jan 7, 2010

Try being explicit about all the border properties. For example:

border:1px solid black;

See Border shorthand property. Although the other bits are optional some browsers don't set the width or colour to a default you'd expect. In your case I'd bet that it's the width that's zero unless specified.