We help IT Professionals succeed at work.

Text arrangement using CSS

nmretd
nmretd asked
on
Medium Priority
218 Views
Last Modified: 2011-09-20
I am trying to simply arrange some text on the same line seperated by some spaces, but not getting anywhere. Can someone help out please ?

<HTML>
<HEAD>
 <TITLE></TITLE>
 <link href="styles.css" type="text/css" rel="stylesheet">
</HEAD>

<BODY BGCOLOR=#FFFFFF>

<div class="container">
      <div class="float1">First Name:</div>
      <div class="float2">Last Name:</div>
</div>

</BODY>
</HTML>
Comment
Watch Question

Why do you need to give First Name and last name different <div>s?  Can you just do:
<div class="container">
     First Name:&nbsp&nbsp&nbsp&nbsp;Last Name:
</div>

Or:
<div class="container">
<table>
  <tr><td width=100px>First Name:</td><td>Last Name:</td></tr>
</table>
</div>

If you want it done with just CSS then there are a bunch of ways, each a little more complicated.
Joe P

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
Jagadeesh MBig Data and Splunk Architect
Commented:
Perhaps using CSS...u could do this..

<div class="container">
     <div class="float1" style="float:left">First Name:&nbsp;&nbsp;&nbsp;</div>
     <div class="float2">Last Name:</div>
</div>


.................................................................................................
&nbsp;   -> insert empty space between the FirstName and LastName

more &nbsp;'s ...more spaces
..................................................................................................
style="float:left" -> is important here to get the div tags in the same line...

Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.