is li element block level elements naturally?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sedigh mohseni
    New Member
    • Feb 2011
    • 64

    is li element block level elements naturally?

    hi

    i'm learning css from w3schools . i look through all examples ,
    i check below code that belongs to http://www.w3schools.com/css/tryit.a...ss_sprites_nav page unfortunatly i cant understand what is display:block; declation for #navlist li selector for , would you please describe me what's cause of use that, i remove that from css then check this html file in my browser in firefox 4 and IE 6 all thing are okay,

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html>
    <head>
    <style type="text/css">
    #navlist{position:relative;}
    #navlist li{margin:0;padding:0;list-style:none;position:absolute;top:0;}
    #navlist li, #navlist a{height:44px;display:block;}
    
    #home{left:0px;width:46px;}
    #home{background:url('img_navsprites.gif') 0 0;}
    
    #prev{left:63px;width:43px;}
    #prev{background:url('img_navsprites.gif') -47px 0;}
    
    #next{left:129px;width:43px;}
    #next{background:url('img_navsprites.gif') -91px 0;}
    </style>
    </head>
    
    <body>
    <ul id="navlist">
      <li id="home"><a href="default.asp"></a></li>
      <li id="prev"><a href="css_intro.asp"></a></li>
      <li id="next"><a href="css_syntax.asp"></a></li>
    </ul>
    </body>
    </html>
    and the other my question is , are'nt li element block level element naturally ?
    thanks alot for your help.
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    it’s probably there because of the #navlist a is not a block element by default and the writer was too lazy.

    Comment

    • macem
      New Member
      • Jun 2011
      • 8

      #3
      don't use w3schools http://w3fools.com :)

      Comment

      • sedigh mohseni
        New Member
        • Feb 2011
        • 64

        #4
        Dormilich dear,
        you think there is'nt any reasonable reason for use that? and the other my question is :
        li element is a block level element naturally, is'nt that ?

        thanks alot.

        Comment

        • macem
          New Member
          • Jun 2011
          • 8

          #5
          Yes li is block element -> http://www.webdesignfromscratch.com/...ck-and-inline/

          Comment

          • webseos
            New Member
            • Nov 2013
            • 1

            #6
            When you are in doubt whether an element is block level or inline just use them and if in browser they appear side by side then they are inline, if they appear one after another vertically , then they are block level.

            Thanks
            Bikram Choudhury

            Comment

            • Dormilich
              Recognized Expert Expert
              • Aug 2008
              • 8694

              #7
              When you are in doubt whether an element is block level or inline just use them ...
              ... or look it up in the DTD. block elements are listed with the %block; entity, inline elements with the %inline; entity.

              Comment

              Working...