...

View Full Version : CSS using div not tables



bakhtn1
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
LOCATION: London
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.

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

<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>
</div>

</body>
</html>

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

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

abduraooft
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