Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Safari/Chrome Developer Tools debug CSS overrides

Safari/Chrome Developer Tools indicate that a CSS rule is overridden by something else by striking it through, as shown in the image.

Striked-through CSS rule

Sometimes I find myself in a situation where I can not figure out from the CSS files what causes this rule to be ignored. But surely Safari itself must know as it strikes it through.

Is there a way to know what overrides such a rule?

like image 318
Laas Avatar asked May 03 '11 23:05

Laas


People also ask

How to use developer tools in Safari to debug websites?

To use Developer tools in Safari, you can use the Safari Develop menu to debug websites and web apps and ensure your website renders fine in all popular web browsers. In case you don’t find the Develop menu in the menu bar, navigate to Safari > Preferences, click Advanced, then select the checkbox ‘Show Develop menu in menu bar’.

How do I use overrides in DevTools?

To use Overrides, open the Devtools either from the settings or using the keyboard shortcut CTRL+SHIFT+I. Then, Click on the Sources tab. You'll see at the top of the left menu 3 tabs: Page, Filesystem, and Overrides. Click on Overrides. Below it you will see " Select folder for overrides." Click on it and choose a folder.

How do I debug JavaScript in DevTools?

DevTools provides a lot of different tools for different tasks, such as changing CSS, profiling page load performance, and monitoring network requests. The Sources panel is where you debug JavaScript. Open DevTools by pressing Command+Option+I (Mac) or Control+Shift+I (Windows, Linux).

How do I find the Old CSS in Chrome DevTools?

Chrome DevTools can help you find the old CSS that is causing your new CSS to not be applied. Figure 1. The max-height: 512px declaration is crossed out. From the Elements panel, open the Computed pane. Figure 2. The Computed pane. Scroll through the list of properties and expand the one that you want to investigate further.


4 Answers

Look at the one which isn't striked out, higher up on the list.

Alternatively, view the computed styles. They will be the definitive applied styles.

like image 176
alex Avatar answered Sep 20 '22 06:09

alex


When you inspect an element, you can show the 'box'. Just bottom of that, you have a 'filter' which should show you every properties being applied to your element.

If you click on a property, it will give you the file and the line number.

enter image description here

like image 39
sheplu Avatar answered Sep 22 '22 06:09

sheplu


Developer Tools will list all rules for an element. Just read through all the CSS rules that apply, and check for a non-struck-through one with the same name.

like image 25
Amadan Avatar answered Sep 19 '22 06:09

Amadan


Go to Elements >> Computed and you'll get the stylesheet that defines the rule you're looking for.

enter image description here

like image 41
jmargolisvt Avatar answered Sep 18 '22 06:09

jmargolisvt