Solved

align 2 spans in div horizontally

Posted on 2011-09-20
4
267 Views
Last Modified: 2012-05-12
Hello All,

IS there a way I can align two spans with   in between in a div to align horizontally

Thank you.
0
Comment
Question by:dojjol
  • 2
4 Comments
 
LVL 40

Accepted Solution

by:
gurvinder372 earned 500 total points
ID: 36568762
<div>
  <span style="padding-right:2px;">column1</span>
  <span>column2</span>
</div>
0
 

Author Comment

by:dojjol
ID: 36568921
Thanks gurvinder372. It worked.

But if I enhance the situation like:

In a div I have 4 spans, in which two spans should be aligned horizontally and two vertically, this fails like

<div>
  <span style="padding-right:2px;">column1</span>
  <span>column2</span>
  <span style="padding-right:2px;">column3</span>
  <span>column4</span>
</div>

Can it be possible to have column 3 display under coulmn 1 and coulmn 4 under coulmn 2.

Thanks and appreciated

0
 
LVL 40

Expert Comment

by:gurvinder372
ID: 36568929
add a <br> after second column
0
 
LVL 13

Expert Comment

by:Andrew Derse
ID: 36568973
Yes I would change it like this:

<div>
  <span style="padding-right:2px;">column1</span>
  <span>column2</span><br />
  <span style="padding-right:2px;">column3</span>
  <span>column4</span>
</div>

The spans will keep appending to the "row" that they are in.  Once you insert a <br /> then it will start a new "row" for you to put more <span>'s in.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Split in Javascript 5 39
Why is this panel heading creating extra space 2 49
Only three borders showing on image 5 18
Decoding Special HTML Characters using Javascript? 2 23
Finding original email is quite difficult due to their duplicates. From this article, you will come to know why multiple duplicates of same emails appear and how to delete duplicate emails from Outlook securely and instantly while vital emails remai…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
In this tutorial viewers will learn how to position overlapping items using z-index in CSS. They will also learn the restrictions on the z-index property.  Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Red.…
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …

816 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now