Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Debugging CSS in Google Chrome

I am writing some CSS files, but when I make a mistake, Chrome appears to just silently ignore the parts that I screw up, and renders the rest.

This makes it annoying to debug since I can't figure out what is going wrong.

So, is there a way to get Chrome to "scream at me in big red letters," so that I can spend less time finding the error and more time fixing it?

like image 538
user1383359 Avatar asked Jun 16 '12 16:06

user1383359


People also ask

How do you debug a CSS error?

When something has gone wrong in your CSS, you can begin by using your favorite browser's built-in DevTools to: toggle off rules one at a time. toggle all rules off and bring them back one at a time. remove or relocate elements.


1 Answers

While you can not "debug" CSS, because it is not a scripting language, you can utilize the Chrome DevTools Elements panel to inspect an element & view the Styles pane on the right. This will give you insights as to the styles being overridden or ignored (line threw). The Styles pane is also useful because of it's ability to LiveEdit the document being inspected, which may help you iron out the issues. If the styles are being overridden, you can then view the Computed Style pane to see the CSS that is actually being utilized to style your document.

To bring up the Chrome DevTools window, hit Ctrl+Shift+I in a Chrome browser tab. (Command+Opt+I for a mac)

For more info visit https://developer.chrome.com/devtools/index

like image 142
Zachariah Moreno Avatar answered Oct 13 '22 07:10

Zachariah Moreno