Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS Blocking CSS to get browser basic HTML

  • This topic is empty.
Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #237766
    gregeckler
    Participant

    I’ve coded a lot of HTML in my past and I’m back doing so on my new Word Press site. I often come across a situation where I want to cancel out the CSS coming from the theme and get basic HTML like I would using a TXT file on my computer.

    Is there a way to have a section of my page that ignores all CSS code?

    #237774
    Paulie_D
    Member

    “View Source” would get you the HTML…wouldn’t it?

    #237775
    Shikkediel
    Participant

    Never mind this post…

    #237787
    gregeckler
    Participant

    Sorry, I don’t think I was clear. I’m writing HTML and when I publish it, the CSS on the website replaces the format I want. Just looking for a way to block all the CSS factors for a section of HTML

    #237790
    Paulie_D
    Member

    Just looking for a way to block all the CSS factors for a section of HTML

    ALL?….Impossible.

    Some…not really…you’d be better off overriding the styles using the specificity and the cascade.

    #237791
    Shikkediel
    Participant

    I think there’s an option with JS but it’s utterly circumventive and quite complex. With cssRules one could actively remove rules from the stylesheet.

    #237793
    Paulie_D
    Member

    With cssRules one could actively remove rules from the stylesheet.

    But only relating to a specific element? Seems unlikely…and pointless.

    This sounds like an XY problem.

    #237798
    Shikkediel
    Participant

    Yeah, you could use the identifiers and test them against a regular expression in the stylesheet. Then delete those rules that match. Or more likely, rewrite them if they are shared with other elements that they should still apply to. Probably quite slow and complicated for sure.

    Not completely pointless under all circumstances… I’ve used cssRules myself to clone some HTML for a magnifier. Then find any unique identifiers and copy the style under a duplicate name so the cloned version won’t violate uniqueness.

    http://ataredo.com/morphology/magnify/

    function transFigure() {
    
        var sheet = document.styleSheets[0],
        styles = sheet.cssRules, rules = [];
    
        $.each(individual, function() {
    
        var tag = this.id, selector = '#' + tag,
        pattern = new RegExp(selector + '(:| |,)');
    
        $.each(styles, function() {
        var string = this.cssText;
        if (pattern.test(string)) {
        var rule = string.replace(selector, selector + '-magnified');
        rules.push(rule);
        }
        });
        $(this).attr('id', tag + '-magnified');
        });
    
        $.each(rules, function() {
        var index = styles.length;
        sheet.insertRule(this, index);
        });
    }
    
    #237888
    RioBrewster
    Participant

    I seriously considered doing this in order to support < IE10.

    If you have a crappy browser, you don’t load CSS at all.

    But I couldn’t figure out how to do it either.

    But if you are looking for a use case for this problem – there it is.

Viewing 9 posts - 1 through 9 (of 9 total)
  • The forum ‘CSS’ is closed to new topics and replies.