Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New Coder
    Join Date
    Jan 2009
    Posts
    84
    Thanks
    5
    Thanked 0 Times in 0 Posts

    keeping this on the same line?

    hello,

    I want some text on the left , and some on the right, but on the same line, because when i use this code it puts the first bit of text on 1 line, and the next bit on the right but on the second line, how can i fix?

    Thanks

    Code:
    <div align="left"><span class="copy">On the left</span>
    <div align="right"><span class="copy">I want this aligned right but on the same line, not on the line below?</span>

  • #2
    Regular Coder ajhauser's Avatar
    Join Date
    Nov 2007
    Location
    Earlville. It's where Earls come from.
    Posts
    226
    Thanks
    74
    Thanked 1 Time in 1 Post
    You need to at least add a class defining the width of your div, or you could float the top div left and the bottom div right - but make sure to check it in several browsers because off the top of my head I know IE and FFox would handle this a little different, but I'm not sure how.

    If this is a list of data and is a valid use for a table, then use a table.

    I think the main message for designers is to get away from tables for layout purposes, but they are fine for diaplaying content as long as it makes sense to use them.

  • #3
    Master Coder Excavator's Avatar
    Join Date
    Dec 2006
    Location
    Alaska
    Posts
    9,675
    Thanks
    22
    Thanked 1,827 Times in 1,811 Posts
    Hello sphinx1994,
    You don't close your divs and I'm not so sure they are needed anyway. If you are trying to do a 2 column layout then it might be done like this demo - http://nopeople.com/CSS/equal_length_columns/index.html

    If it's just two lines of text then the spans should be enough markup to control it.
    Try it like this -
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    <style type="text/css">
    html, body {
    	font: 14px "Comic Sans MS";
    	background: #FC6;
    	text-align: center;
    }
    * {
    	margin: 0;
    	padding: 0;
    	outline: none;
    	border: none;
    }
    #container {
    	width: 800px;
    	margin: 30px auto;
    	background: #999;
    	overflow: auto;
    }
    .left {
    	float: left;
    }
    .right {
    	float: right;
    }
    </style>
    </head>
    <body>
        <div id="container">
    		<span class="left">On the left</span>
    		<span class="right">I want this aligned right but on the same line, not on the line below?</span>
        <!--end container--></div>
    </body>
    </html>
    Validate often DURING development - Use it like a splelchecker | Debug during Development |Write it for FireFox, ignore IE
    Use the right DocType | Validate your markup | Validate your CSS | Why validating is good | Why tables are bad

  • #4
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,851
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    I want some text on the left , and some on the right, but on the same line, because when i use this code it puts the first bit of text on 1 line, and the next bit on the right but on the second line, how can i fix?
    Code:
    <div ><span >On the left</span>
    <span>I want this aligned right but on the same line, not on the line below?</span>
    </div>
    ?
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #5
    New to the CF scene
    Join Date
    May 2009
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    pls close the div

    <div align="left"><span class="copy">On the left</span></div>
    <div align="right"><span class="copy">I want this aligned right but on the same line, not on the line below?</span></div>

    try this.....


  •  

    Posting Permissions

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