CSS :Not attribute

HtmlCssCss Selectors

Html 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% };

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionSanya530View Question on Stackoverflow
Solution 1 - HtmlBoltClockView Answer on Stackoverflow
Solution 2 - HtmlzzzzzzzzzView Answer on Stackoverflow
Solution 3 - HtmlBrian SaltaView Answer on Stackoverflow
Solution 4 - HtmlZlatko SoleniqView Answer on Stackoverflow