Examinar e editar CSS

Pode examinar e editar CSS no painel de CSS do Inspetor.

Examinar regras de CSS

visualização de Regras lista todas regras que se aplicam ao elemento selecionado, ordenada pela mais específica para a menos específica:

The Rules view lists user-agent styles (styles applied by the browser) if the option to do so is checked in the developer tool settings. Note that this setting is independent of the "Browser styles" checkbox in the Computed view.

The Rules view displays all authored styles, including styles that are not supported or that are invalid. This can help you understand why certain styles are not being applied:

Exibir regra

It displays each rule as in a stylesheet, with a list of selectors followed by a list of property:value; declarations.

  • Highlight matched elements: next to the selector is a target icon: click this to highlight all nodes in the page that match this selector.
  • Overridden declaration: declarations that are overridden by later rules are crossed out. See overridden declarations.
  • Show cascade: next to overridden declarations is a magnifying glass: click this to see the cascade of rules containing the overridden property. See overridden declarations.
  • Enable/disable: if you hover over a declaration, a checkbox appears next to it: you can use this to toggle the declaration on or off.
  • Filename and line number: on the right-hand side is a link to the rule. See link to CSS file.

Starting in Firefox 52, if the element has a display: grid declaration, then it gets a grid icon next to it, like this: . Click that icon to display the grid overlaid on the page, including grid lines and tracks. See Examine grid layouts for more on this.

User-agent styles are displayed with a different background, and the link to the filename and line number contains the prefix (user agent):

element {} rule

The element {} rule at the top of the rules list isn't actually a CSS rule. It represents the CSS properties assigned to the element via its style attribute.

Starting in Firefox 52, this also gets the target icon: , giving you a convenient way to highlight the currently selected element in the page.

Filtrar regras

There's a box at the top of the Rules view labeled "Filter Styles":

As you type:

  • any rules which don't contain the typed string at all are hidden
  • any declarations which contain the typed string are highlighted

Click the "X" at the end of the search box to remove the filter.

While in the Rules view, you can press Ctrl / Cmd + F to focus the search field. Once you've typed in a filter, you can press Esc to remove it again.

By default, the search box highlights all declarations which contain any part of the string. For example, searching for "color" will highlight declarations containing border-bottom-color and background-color as well as just color.:

If you enclose the search query in ticks, like this: `color`, the search is restricted to exact matches:

Expanding shorthand properties

Shorthand properties can be expanded to display their related longhand properties by clicking the arrow besides them.

Displaying pseudo-elements

The Rule view displays the following pseudo-elements, if they are applied to the selected element:



If the selected element has pseudo-elements applied to it, they are displayed before the selected element but hidden by a disclosure triangle:

Clicking the triangle displays them:

Setting :hover, :active, :focus

There's a button to the right of the filter box:

Click the button to see three checkboxes, which you can use to set the :hover (en-US), :active (en-US) and :focus (en-US) pseudo-classes for the selected element:

This feature can also be accessed from the popup menu in the HTML view.

If you set one of these pseudo-classes for a node, an orange dot appears in the markup view next to all nodes to which the pseudo-class has been applied:

Hiperligação para ficheiros CSS

At the top right of each rule, the source filename and line number is displayed as a link: clicking it opens the file in the Style Editor.

You can copy the location of the source file: right-click the link and select "Copy Location".

The Inspector understands CSS source maps. That means that if you are using a CSS preprocessor that has support for source maps, and you've enabled source map support in the Style Editor settings, then the link will take you to the original source, not the generated CSS. Read more about CSS source map support in the Style Editor documentation.

Obter ajuda para as propriedades de CSS

If you context-click on a CSS property name in the Rules view, you can open a popup displaying help for that property from MDN:

Note that for the moment, this doesn't cache responses from MDN, so it requires network connectivity.

Overridden declarations

If a CSS declaration is overridden by some other CSS rule with a greater weight, then the declaration is shown with a line through it.

Overridden declarations have a magnifying glass next to them. Click the magnifying glass to filter the rule view to show only the rules applying to the current node that try to set the same property: that is, the complete cascade for the given property.

This makes it easy to see which rule is overriding the declaration:

Examinar CSS computada

To see the complete computed CSS for the selected element, switch to the Computed view. This shows the calculated value that each CSS property has for the selected element:

You can Tab through them to select them, and from Firefox 49 onwards, you can find more information about these properties — pressing F1 on a selected property will open up its MDN reference page.

Clicking the arrow next to the property name (or pressing Enter or Space while it is selected) shows the rule that set this value, along with a link to the source filename and line number:

By default, this view only shows values that have been explicitly set by the page: to see all values, click the "Browser styles" box. You can Tab through the filenames/line numbers; pressing Enter/Return will open up the relevant file at that point in the Style Editor.

Typing in the search box performs a live filtering of the list, so, for example, if you just want to see font-related settings, you can type "font" in the search box, and only properties with "font" in the name will be listed. You can also search for the values of properties: to find the rule responsible for setting the font to "Lucida Grande", type that in the search box.

While in the Computed view, you can press Ctrl / Cmd + F to focus the search field. Once you've typed in a filter, you can press Esc to remove it again.

Editar regras

If you click on a declaration or a selector in the Rules view you can edit it and see the results immediately. You can also Tab through the different existing properties and values, and start editing them by pressing Enter or Space. To add a new declaration to a rule, click on the last line of the rule (the line occupied by the closing brace).

As you start typing a property name, you'll see a list of autocomplete suggestions. Press Tab to accept the current suggestion or Up and Down to move through the list. The default choice is the most common property that starts with the letters you've typed. For example, here the user has typed "c" and the default choice is "color":

If you enter an invalid value for a property when editing it, or an unknown property name, a yellow alert icon appears besides the declaration.

Any changes you make are temporary: reloading the page will restore the original styling.

You can use the arrow keys to increase/decrease numeric rules while editing. The Up arrow will turn "1px" to 2px, and Shift + Up/Down will increment by 10. Alt + Up/Down change values by 0.1, and Shift + Page up/Page down will add or subtract 100 from the value.

Edits that you make in the Rules view are reflected in the Style Editor, and vice versa.

Starting in Firefox 52, if you're editing CSS, the context menu you'll see is the normal one for working with editable text:

Adicionar regras

You can add new rules in the Rules view. Just right-click to show the context menu and select "Add rule". This will add a new CSS rule whose selector matches the currently selected node.

There's also a button that enables you to do the same thing:

Copiar regras

To copy rules, and pieces of rules, use one of the following context menu items in the Rules view:

  • Copy Rule
  • Copy Selector
  • Copy Property Declaration
  • Copy Property Name
  • Copy Property Value

Consultar também

  • Lista completa dos talhos de Teclado do Inspetor de Página.
  • The Inspector also includes a number of specialized tools for working with particular CSS features, such as colors, fonts, and animations. To read about these see the list of guias de como....