[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

align 2 spans in div horizontally

Posted on 2011-09-20
4
Medium Priority
?
273 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:
Gurvinder Pal Singh earned 2000 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:Gurvinder Pal Singh
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

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…
Suggested Courses

834 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