Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable CSS in Browser for testing purposes

Tags:

html

browser

css

People also ask

How do I view a webpage without CSS?

Select the "CSS" option in the Web Developer extension and click "Disable All Styles," or click the "Style Sheets" option in Pendule and click "Disable All Styles." After you click the option, the page will re-display without the styles.

How do I block a CSS file?

You can open the Network tab in Dev Tools and find the particular CSS file that you want to disable. Right click on it and select "Block request URL", then refresh the page (make sure "disable cache" is checked at the top of your dev tools as well).

How do I disable CSS in Firefox?

Hit Alt, then go to View>Page Style. From there you can select Basic or No Style, easily disabling CSS.

How do I turn off CSS in Safari?

But first, here's how to disable CSS Firefox: View > Page Style > No Style. Safari: Safari > Preferences... > Show Develop menu in menu bar . Then go to the Develop dropdown and select the “Disable Styles” option.


In Chrome/Chromium you can do this in the developer console.

  1. Bring up the developer console by either ctrl-shift-j or Menu->Tools->Developer Console.
  2. Within the developer console browse to the Sources tab.
  3. In the top-left corner of this tab is an icon with a disclosure triangle. Click on it.
  4. Browse to <domain>→css→<css file you want to eliminate>
  5. Highlight all of the text and hit delete.
  6. Rinse and repeat for each stylesheet you want to disable.

The Web Developer plugin for Firefox and Chrome is able to do this

Once you have installed the plugin the option is available in the CSS menu. For example, CSS > Disable Styles > Disable All Styles

Alternatively with the developer toolbar enabled you can press Alt+Shift+A.


Firefox (Win and Mac)

  • Via the menu toolbar, choose: "View" > "Page Style" > "No Style"
  • Via the Web Developer Toolbar, choose: "CSS" > "Disable Styles" > "All Styles"

If the Web Dev Toolbar is installed, people can use this keyboard shortcuts: Command + Shift + S (Mac) and Control + Shift + S (Win)

  • Safari (Mac): Via the menu toolbar, choose "Develop" > "Disable Styles"
  • Opera (Win): Via the menu, choose "Page" > "Style" > "User Mode"
  • Chrome (Win): Via the gear icon, choose the "CSS" tab > "Disable All Styles"
  • Internet Explorer 8: Via the menu toolbar, choose "View" > "Style" > "No Style"
  • Internet Explorer 7: via the IE Developer Toolbar menu: Disable > All CSS
  • Internet Explorer 6: Via the Web Accessibility Toolbar, choose "CSS" > "Disable CSS"

This script works for me (hat tip to scrappedcola)

var el=document.getElementsByTagName('*');for(var i=0;i<el.length; i++){if (el[i].getAttribute("type")=="text/css") el[i].parentNode.removeChild(el[i]); };

inline style stays intact, though


Expanding on scrappedocola/renergy's idea, you can turn the JavaScript into a bookmarklet that executes against the javascript: uri so the code can be re-used easily across multiple pages without having to open up the dev tools or keep anything on your clipboard.

Just run the following snippet and drag the link to your bookmarks/favorites bar:

<a href="javascript: var el = document.querySelectorAll('style,link');
         for (var i=0; i<el.length; i++) {
           el[i].parentNode.removeChild(el[i]); 
         };">
  Remove Styles 
</a>
  • I would avoid looping through the thousands of elements on a page with getElementsByTagName('*') and have to check and act on each individually.
  • I would avoid relying on jQuery existing on the page with $('style,link[rel="stylesheet"]').remove() when the extra javascript is not overwhelmingly cumbersome.

Install Adblock Plus, then add *.css rule in Filters options (custom filters tab). The method affect only on external stylesheets. It doesn't turn off inline styles.

Disable all external CSS

This method does exactly what you asked.


Delete <head> with a bookmarklet

For pages that rely on external CSS (most pages nowadays) you can delete the head element:

document.querySelector("head").remove();

Usage: right-click the page (in Chrome/Firefox), select Inspect, paste the code above in the devtools console and press Enter.

A bookmarklet version of the same code that you can paste as the URL of a bookmark:

javascript:(function(){document.querySelector("head").remove();})()

Now clicking the bookmark in your Bookmarks bar will (hopefully) strip all the css stylesheets.

Delete <head> via devtools

Another way to achieve it is to right-click the page (in Chrome/Firefox), select Inspect, in devtools panel, Elements tab select the <head> tag (see screenshot), right-click it, and pick Delete element:

delete the head tag

Note: Removing the head will not work for pages that use inline styles.

Safari-only solution

If you happen to use Safari on MacOS then:

  1. Open Safari Preferences (cmd+,) and in the Advanced tab enable the checkbox "Show Develop menu in menu bar".
  2. Now under the Develop menu you will find a Disable Styles option.