1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

no line break between 2 div's

Discussion in 'CSS' started by abcdefGARY, Feb 18, 2007.

  1. #1
    hi, i'm having a minor issue, well major issue. i have both div's side by side and would like them to appear side by side, however, it seems that they always add an extra line break.

    for example:

    <div>hello</div><div style="font-weight: bold;">there</div>
    Code (markup):
    I would like it to look like:

    hello [b]there[/b]
    Code (markup):
    however, it always looks like:

    hello
    [b]there[/b]
    Code (markup):
    I hope i've made myself clear, and if anyone could direct me how to address this issue, i'd be more than happy to give some rep. thanks
    SEMrush
     
    abcdefGARY, Feb 18, 2007 IP
    SEMrush
  2. dkessaris

    dkessaris Peon

    Messages:
    984
    Likes Received:
    119
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You can just float the first div to the left
     
    dkessaris, Feb 18, 2007 IP
  3. abcdefGARY

    abcdefGARY Peon

    Messages:
    665
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #3
    mm, not quite the answer i was looking for. is there a better alternative?

    because i'm trying to create a menu which have bordered boxes around them and there are multiple items. kind of like:

    <div id="menu">Home</div><div id="menu">About Us</div><div id="menu">Contact</div>
    Code (markup):
     
    abcdefGARY, Feb 18, 2007 IP
  4. dkessaris

    dkessaris Peon

    Messages:
    984
    Likes Received:
    119
    Best Answers:
    0
    Trophy Points:
    0
    #4
    The best way to do that is probably using an inline list, check this article, I believe it will help
     
    dkessaris, Feb 18, 2007 IP
  5. tgo

    tgo Peon

    Messages:
    124
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Span... same as div but can be placed inline with no problems.
     
    tgo, Feb 18, 2007 IP
  6. nwk

    nwk Well-Known Member

    Messages:
    385
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    108
    #6
    How about using <table>? Using <td> you can make inline list.
     
    nwk, Feb 18, 2007 IP
  7. sketch

    sketch Well-Known Member

    Messages:
    898
    Likes Received:
    26
    Best Answers:
    0
    Trophy Points:
    148
    #7
    If you have to have DIVs, multiple DIVs that are supposed to line up on one line, they must all have "float: <left|right>" in the style. This may require whatever is beneath these DIVs to have the "clear: both" property.

    The only other alternative is using SPAN as tgo said.
     
    sketch, Feb 18, 2007 IP
  8. kk5st

    kk5st Prominent Member

    Messages:
    3,486
    Likes Received:
    367
    Best Answers:
    28
    Trophy Points:
    335
    #8
    That is a completely improper use of the div element. The purpose of the markup is to label each part of the document for what it is. In the case of a menu, it is by definition, a list. Get your markup correct, and we'll be better able to deal with the presentation.

    cheers,

    gary
     
    kk5st, Feb 18, 2007 IP
  9. Clive

    Clive Web Developer

    Messages:
    4,507
    Likes Received:
    296
    Best Answers:
    0
    Trophy Points:
    250
    #9
    As simple as the code below:
    <div style="display:inline">Hello</div> <div style="display:inline">There</div>
    Code (markup):
     
    Clive, Feb 19, 2007 IP