What to use instead of <DIV>

Discussion in 'CSS' started by coolistdude, Apr 6, 2009.

  1. #1
    I have a menu script but when I insert <div> </div> code its making it skip a line and not properly aligned, is there anything else I can use instead? :)
     
    coolistdude, Apr 6, 2009 IP
  2. qazu

    qazu Well-Known Member

    Messages:
    1,834
    Likes Received:
    62
    Best Answers:
    0
    Trophy Points:
    165
    #2
    Take the padding and margin out of the div - .divname {padding:0;margin:0;}
     
    qazu, Apr 7, 2009 IP
  3. dlb

    dlb Member

    Messages:
    203
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    35
    #3
    Use <span> instead. They stay on the same line.
     
    dlb, Apr 7, 2009 IP
  4. Rikesh

    Rikesh Active Member

    Messages:
    139
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    63
    #4
    I agree with dlb. The only difference between <span> and <div> is that <div> forces a line break.
     
    Rikesh, Apr 9, 2009 IP
  5. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,999
    Best Answers:
    253
    Trophy Points:
    515
    #5
    No, one is block-level, and one is inline-level, and should only be used when appropriate to each. DIV is for grouping together sets of related information, span is for quick and dirty cdata formatting or other inline-level containers/sandbags.

    The PRESENTATIONAL side the block level container does default to display:block, but display:block and display:inline from a presentational standpoint has NOTHING to do with the HTML 'level' of an element.

    Though if this is a menu, I have to ask why you are using DIV's in it since a menu is a list, that's what unordered lists are for (since they deprecated MENU)

    Could we see your actual code? I think you are probably doing something wrong.
     
    deathshadow, Apr 10, 2009 IP
  6. Rikesh

    Rikesh Active Member

    Messages:
    139
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    63
    #6
    Wow... Thanks deathshadow :)
     
    Rikesh, Apr 11, 2009 IP
  7. gopalraju

    gopalraju Peon

    Messages:
    11
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Agree with deathshadow. ul li is the best for menus.
     
    gopalraju, Apr 12, 2009 IP
  8. dlb

    dlb Member

    Messages:
    203
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    35
    #8
    I'm pretty sure unordered lists were intentionally for that, unordered list items. They've been spliced with CSS to become usable as menus now, but for a time they weren't considered for that.
     
    dlb, Apr 22, 2009 IP
  9. Stomme poes

    Stomme poes Peon

    Messages:
    3,195
    Likes Received:
    136
    Best Answers:
    0
    Trophy Points:
    0
    #9
    A list of links is what a site navigation group IS. A random link here or there is not. Like any list, it's not complete if it doesn't have all the list items.

    grocery list:
    coffee
    tea
    milk
    meusli
    eggs

    while I can take any item out and it's still a list, it's no longer my complete grocery list. Why is it a list instead of just random items? They share something in common: they were written down next to each other because they are all things I have to buy today.

    So, this is why a site menu is considered a list of links, instead of a sequence of otherwise unrelated links (those exist too). But it was a while before web standardistas thought of them that way.
     
    Stomme poes, Apr 24, 2009 IP
  10. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,999
    Best Answers:
    253
    Trophy Points:
    515
    #10
    http://www.w3.org/TR/1998/REC-html40-19980424/struct/lists.html#h-10.4

    So unless you've not updated your skillsets since 1998, or have been learning from sources that haven't; The latter being a monster problem with 95% of books on shelves and 99% of educators being a decade or more behind the curve...
     
    deathshadow, Apr 24, 2009 IP