div, css and columns

A

Aioe

A php script returns an output like this:

<div class="sinistra">
<dl>
<dt>qualcosa</dt>
<dd>altro</dd>
[...]
</dl>
</div>

<div class="destra">
<dl>
<dt>qualcosa</dt>
<dd>altro</dd>
[...]
</dl>
</div>

i need a way to display these structures in two parallel columns (somewhat
like the result of:

<table>
<tr>
<td>
[contents of first div structure]
</td>
<td>
[contents of second div structure]
</td>
</tr>
</table>

is this possibile using *only* the css styles? If so, how can i *vertically*
align these div structures? (they must start in the same row)

thank you

cheers
 
M

Mark Parnell

In our last episode said:
i need a way to display these structures in two parallel columns
is this possibile using *only* the css styles? If so, how can i *vertically*
align these div structures? (they must start in the same row)

..sinistra, .destra { float: left; width: 45%; }

Depending on the context that may need adjusting, but should get you on
the right track.
 
A

Andy Dingley

Aioe said:
is this possibile using *only* the css styles?

Yes, because CSS applies to tables as well as <div>s.

However it's _not_ possible to generate the exact presentation just by
using two <div>s as you have here. A table is composed of cells within
rows. The two <div>s each containing a list is composed of two columns
that each contain cells (like newspaper columns). You'll find it hard
to control vertical alignments. If this isn't a problem for this
example, then follow Mark's advice with the floats.

I'd suggest keeping the <table> and applying CSS to that. If you have
"content" that really needs to be aligned in rows like this, then IMHO
that's a reasonable justification for regarding it as a "data table".

It's also possible to apply "table CSS" to non table HTML markup. This
was really developed as an idea for rendering XML (not HTML) purely
with CSS and making it look like a table. XML/CSS turned into a bit of
a dead end and so the whole idea has never been widely implemented
(i.e. don't use it).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,015
Latest member
AmbrosePal

Latest Threads

Top