Results 1 to 5 of 5

Thread: [xhtml + css] text in div or p not going to next line

  1. #1
    Join Date
    Nov 2006
    Location
    Pennsylvania
    Beans
    423

    [xhtml + css] text in div or p not going to next line

    i have some content text i am trying to print and instead of going to the next line, the text continues running horizontally.

    here are some snippets of code.

    xhtml:
    PHP Code:
    <!-- ENDING HORIZONTAL NAV -->
        </
    div>



        <!-- 
    NOTE SURE IF THIS IS A GOOD IDEA BUT OPENING 'CONTENT' DIV -->
        <
    div id="index_0-0"

        
        
    hahsefkawtujhawjfnjsanbdvifasigffkjnsalfknaosihgfo;asgfo

        
        
        
    <!-- CLOSING ID_0--->i
        
    </div>

        <
    div id="index_0-1"

        
        
    hahsefkawtujhawjfnjsanbdvifasigffkjnsalfknaosihgfo;asgfo

        
        
        
    <!-- CLOSING ID_0--->
        </
    div>
        <!-- 
    FOOTER --> 
    css:
    PHP Code:
    div#index_0-0 {

    padding:2px 2px;
    margin:2px 2px;
    float:left;
    width:281px;

    }
    div#index_0-1 {

    margin:2px 2px;
    padding:2px 2px;
    float:right;
    width:281px;

    Your Ubuntu User number is # 15355

    A must Read for anyone interested in Computer Programming.

  2. #2
    Join Date
    Jul 2008
    Beans
    1,491

    Re: [xhtml + css] text in div or p not going to next line

    Because you use float.
    The simple way is to add a <br />.

  3. #3
    Join Date
    Nov 2006
    Location
    Pennsylvania
    Beans
    423

    Re: [xhtml + css] text in div or p not going to next line

    Quote Originally Posted by Reiger View Post
    Because you use float.
    The simple way is to add a <br />.
    how should i do it then?

    by pixel?
    Your Ubuntu User number is # 15355

    A must Read for anyone interested in Computer Programming.

  4. #4
    Join Date
    Jul 2008
    Beans
    1,491

    Re: [xhtml + css] text in div or p not going to next line

    No float is fine by any means, but because it was originally designed with just images in mind (or so I read somewhere, anyway) it has the side effect of turning a block element into an inline element. Thus why your divs align alongside each other without line break (news paper column style, so to speak); hence you need the br.

    I think this should do it:
    <div>
    <div style="float:left;">Whee, I believe I can fly!</div><br />
    <div style="float:right;">Float to the right.</div></div>

  5. #5
    Join Date
    Oct 2005
    Location
    Netherlands
    Beans
    350

    Re: [xhtml + css] text in div or p not going to next line

    You should not use breaks here, if you want content to start on a new line after a float, use
    Code:
    clear: left;
    in your css for index0-1, or
    Code:
    clear: right;
    for the other way around.
    But why are you using floats here in the first place? What are you trying to do?

    Hope this helps a bit

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •