Alec Smart
Alec Smart

Reputation: 95880

Ignore CSS tags

Am wondering if there is a way to ignore tags:

<!-- I can add code here -->

<!-- I cannot edit the following start -->
<style>
     div, td {
     color: #555555;
     font-size: 10pt;
     text-align: left; 
     }
</div>
<!-- I cannot edit the following end -->

<div id="myapp" style="color:red"><div>Test</div></div>

Am wondering if there is anything that I can add to skip these generic div/td styles. e.g. #myapp div { font-color: inherit; }

Upvotes: 0

Views: 705

Answers (2)

Rob W
Rob W

Reputation: 348972

There is no straightforward CSS method to ignore later CSS rules.

The most reliable option is to use JavaScript to remove the tag.

Example: Remove the, say, first <style> tag after the <script> element:

<script id="unique-id-script">
setTimeout(function() {
    var removeTheNthStyleElement = 1, found = 0,
        script = document.getElementById('unique-id-script'), elem = script;
    while (elem = elem.nextSibling) {
        if (elem.nodeName.toUpperCase() === 'STYLE') {
            if (++found === removeTheNthStyleElement) {
                // Remove style element => disable styles
                elem.parentNode.removeChild(elem);
                // Remove temporary script element
                script.parentNode.removeChild(script);
                break;
            }
        }
    }
}, 4);
</script>
... anything but a style element...
<style>
/* I want to prevent these rules from being used */
</style>

Upvotes: 2

Praveen Vijayan
Praveen Vijayan

Reputation: 6761

This will inherit red color

#myapp div{
  color: inherit;
}

Upvotes: 0

Related Questions