Forums

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
    Posts
  • #38500
    alextash
    Participant

    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: http://www.hv-designs.co.uk/2009/10/12/hosting-layout-2-sitebuild-pt1/
    (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).

    #104527

    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.

    #104551
    wolfcry911
    Participant

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

    #104553
    Senff
    Participant

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

    #104566
    alextash
    Participant

    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.