View Full Version : CSS using div not tables

05-21-2012, 04:27 PM
how do you align text in css onlyusing divs and no tables such that the output looks like this:

INVITED BY: John Steward
INFO: Some info
INFORMATION: Some more info

I want the left part to align to the right and the right part to align to the left.

Thank you.

05-21-2012, 04:37 PM
Display <span>'s inline-block which will allow you to specify a width.

<!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">
<style type="text/css">
#info span {
display: inline-block;
width: 130px;

<div id="info">
<div><span>INVITED BY:</span> John Steward</div>
<div><span>INFO:</span> Some info</div>
<div><span>LOCATION:</span> London</div>
<div><span>INFORMATION:</span> Some more info</div>


05-22-2012, 02:10 PM
Why is it hard to do tables in divs?

05-22-2012, 02:14 PM
I think its becuase you use css instead of align attributes

05-22-2012, 02:19 PM
Anyway, that looks more like a tabular data and hence a <table> (with proper <th>) would be the most appropriate element to be used here.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum