Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

colspan equalent in css? [duplicate]

Tags:

html

css

There's a first table row that looks like this:

....

<tr>
   <th colspan="2">Add a category</th>
</tr>

...

It renders correctly. However I want it to be without colspan attribute, but styled in CSS instead. And the reason for that is because there are a lot of similar tables, so it wouldn't require to define the attribute over and over again (just adhering to DRY principle)

I just want it to be as:

<tr>
   <th>Add a category</th>
</tr>

// CSS
table th:first-child {
    /* Pseudo attr */
    colspan : 2px;
}

I've tried playing with float, padding and width with no success. Is there any way to do that in pure CSS?

like image 416
Yang Avatar asked Sep 14 '26 01:09

Yang


1 Answers

As far as I know, there's no way to do that with pure CSS because colspan is really more layout than style.

According to this, It appears that it was supported on some past browsers, but seems to really be not recommended and unsupported in the present day.

like image 68
Ruslan Avatar answered Sep 16 '26 20:09

Ruslan