CSS :Not attribute
HtmlCssCss SelectorsHtml Problem Overview
I have a few HTML tables. These tables do not have CSS classes. The two tables have width="100%"
attribute. Other tables don't have the width
attribute.
Using only CSS I need to set the width of the tables which don't have width=100%
. Something like this:
table:not(width="100%"){
width: myValue;
}
Html Solutions
Solution 1 - Html
Attribute selectors are surrounded by []
, so your selector should look like this instead:
table:not([width="100%"]) {
width: myValue;
}
Solution 2 - Html
use a class on that table and put that in the not
table:not(.foo) {
}
you need a selector in the not and width = 100% is not one
Solution 3 - Html
How about using inline styles for the tables you want to have different widths?
<table style="width:95%">
<tr>
<td></td>
</tr>
</table>
OR a separate class:
<table class="customWidth">
<tr>
<td></td>
</tr>
</table>
CSS:
table { width:100%; }
table.customWidth { width:95%; }
Solution 4 - Html
just write in the css folder table { width: 100% };