- This topic is empty.
-
AuthorPosts
-
February 6, 2016 at 7:49 am #237766
gregeckler
ParticipantI’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?
February 6, 2016 at 12:09 pm #237774Paulie_D
Member“View Source” would get you the HTML…wouldn’t it?
February 6, 2016 at 12:50 pm #237775Shikkediel
ParticipantNever mind this post…
February 6, 2016 at 10:14 pm #237787gregeckler
ParticipantSorry, 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
February 7, 2016 at 4:29 am #237790Paulie_D
MemberJust 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.
February 7, 2016 at 9:17 am #237791Shikkediel
ParticipantI 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.February 7, 2016 at 11:24 am #237793Paulie_D
MemberWith 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.
February 7, 2016 at 7:12 pm #237798Shikkediel
ParticipantYeah, 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); }); }
February 9, 2016 at 3:27 pm #237888RioBrewster
ParticipantI 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.
-
AuthorPosts
- The forum ‘CSS’ is closed to new topics and replies.