text next to image

Discussion in 'CSS' started by rosytoes, Feb 22, 2006.

  1. #1
    I have some code like this:
    <h3>title1</h3>
    <p><img>text</p>
    <h3>title2</h3>
    <p>text</p>
    Code (markup):
    My problem is when I put a float: left image before the text and if the text is not long enough to clear the image, the next <h3> title just follows on next to the image instead of starting on a new line. If i include a clear: left in my <h3>, it clears my sidebar menu as well which is also float: left.

    How would I solve this?
     
    rosytoes, Feb 22, 2006 IP
  2. Huvet

    Huvet Member

    Messages:
    16
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    38
    #2
    Move the <img> out of the <p>...</p> and float it. You should be fine.
     
    Huvet, Mar 3, 2006 IP
  3. hooperman

    hooperman Well-Known Member

    Messages:
    646
    Likes Received:
    23
    Best Answers:
    0
    Trophy Points:
    108
    #3
    another option is to use 'clear'.

    If you put content in a div after the floated image, use this:
    #content {
      clear: left;
    }
    Code (markup):
    This clears elements that have been floated left. If you use clear: both; this clears both left and right floated elements.
     
    hooperman, Mar 3, 2006 IP
  4. Tam

    Tam Peon

    Messages:
    89
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Tam, Mar 5, 2006 IP