The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS Why to declare display block for block elements?

  • This topic is empty.
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
  • #38500

    Hi guys, I’ve seen many times when people declare display block for ul, li, p. (They dont do that to override any previosly set properties). For example, I’ve seen that in this tutorial too:
    (just search the page and you’ll find

     .nav-links li {
    display: block;
    float: left;
    background-image: url(../images/nav_divider.png);
    background-repeat: no-repeat;
    background-position: right 22px;

    I’m the beginner and wonder why do we need to do that (except overriding).


    If they aren’t overriding an existing style then I cannot think of a good reason why it should be there. I wouldn’t worry about including it at all.


    Even if there was a preexisting display property, it is not needed because the float overrides it…


    @wolfcry911: a float doesn’t turn a block-level element into inline, or vice versa, so not sure what you mean by that…?


    I was wondering about that too. So I guess we dont need that. For Senff, floated elements always become block level elements (inline elements turn to block elements).

Viewing 5 posts - 1 through 5 (of 5 total)
  • The forum ‘CSS’ is closed to new topics and replies.