John Smith
John Smith

Reputation: 6207

Dynamic width for div (table like)

I would like to do the following with CSS:

name1111 | x | name222  | dateeee | x
name11   | x | name22   | dateee  | x
name111  | x | name2222 | dateeee | x
name1    | x | name22   | daeee   | x

I would like every column be the maximum width. I meant, no fixed widths but the longest content would set it. How to do it? It used to be easy with tables, but seems impossible now

Upvotes: 0

Views: 355

Answers (3)

Andy
Andy

Reputation: 14575

There is ways to do this with CSS, but it would be a lot more complex than using a simple table. A table is absolutely fine in this case. Imagine if you were making a poster in word, yo wouldn't use a table for layouts, but you would if you had a table of data to show. Same thing

Upvotes: 1

Qiang
Qiang

Reputation: 656

You could use : float: left; and text-align: left.

Upvotes: 1

BonyT
BonyT

Reputation: 10940

That's a table, so use one.

It's a myth that tables are deprecated - using tables for page LAYOUT is considered bad - using tables for PRESENTING DATA is using the right tool for the right job.

Upvotes: 9

Related Questions