Reputation: 7565
In my website, text is dynamically appended to the page.
My need if the td
has attribute has colspan=2
, apply text-align:center
.
tblCustomers tr td
{
padding-left:25px;
}
//how do I do this
tblCustomer tr td:hasattribute(colspan=2)
{
text-align:center;
}
Note:-
Upvotes: 1
Views: 64
Reputation: 1889
Just added width: 100%
to your table so you see visualize the effect properly.
.tblCustomer
{
width: 100%;
}
.tblCustomer tr td[colspan="2"]
{
text-align:center;
}
<table class="tblCustomer">
<tr>
<td colspan="2">Jill</td>
<td>Smith</td>
<td>50</td>
</tr>
</table>
Upvotes: -1
Reputation: 43
in order to apply a style to all td's with a specific colspan, you can use the following selector:
td[colspan="2"]
or more specifically:
td[colspan="2"]{
text-align:center;
}
source: https://www.w3.org/TR/1998/PR-CSS2-19980324/selector.html
Upvotes: 1
Reputation: 8407
add this style , make sure to define this tblCustomer
class
or id
, for eg: I've put this as class
.tblCustomer tr td[colspan="2"]{
text-align:center;
}
Upvotes: 1
Reputation: 9470
Here is a solution
tblCustomer tr td[colspan="2"]
{
text-align:center;
}
Upvotes: 0
Reputation: 14169
add this way
tblCustomers tr td {
padding-left:25px;
}
tblCustomers tr td[colspan="2"] {
text-align:center;
}
https://jsfiddle.net/nsse87c4/
Upvotes: 2
Reputation: 944426
CSS2 introduced four attribute selectors:
…
[att=val]
Represents an element with the att attribute whose value is exactly "val".
Upvotes: 0