Stephane
Stephane

Reputation: 5078

Div element set as block. Why?

I sometimes see DIV set to display:block Is there any particular reason considering DIV is already a block box.

Upvotes: 4

Views: 218

Answers (3)

Martin Lyne
Martin Lyne

Reputation: 3065

You could be over-riding another CSS attribute that said

.myClass {
  display: inline;
}

Or replacing display:none; to "un-hide" it (typically this is done on-the-fly by javascript).

Upvotes: 11

RhinoWalrus
RhinoWalrus

Reputation: 3089

If you're overriding an existing style it makes sense. Setting a div to block that has no styles coming in from elsewhere does not.

Upvotes: 2

Niet the Dark Absol
Niet the Dark Absol

Reputation: 324620

It may be to override another style that may be setting it to something else, but otherwise it's most likely a reminder to whoever wrote it. There's no real reason to include that rule.

Upvotes: 4

Related Questions