Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

Examinar e editar CSS

Esta tradução está incompleta. Ajude atraduzir este artigo.

Você pode examinar e editar CSS no painel CSS do Inspetor.

Analisar regras de CSS

A visualização das listas de todas egras que se aplicam a um elemento selecionado são ordenados das formas mais específica até a menos específica:

As regras também podem ser visualizadas pelo estilo de agente-visualizador (estilos que são aplicados pelo navegador), para ativar esta opção, a própria dever ser marcada nas configurações da barra de ferramentas. Note que essa configuração é independente da checkbox "Estilo do Navegador" na aba de visualização de estilos "Computado".

Do Firefox versão 44 em diante, todas as Regras do CSS são exibidas, including styles that are not supported or that are invalid. This can help you understand why certain styles are not being applied:

Regra de exibição

Cada regra é exibida como uma folha de estilo, com uma lista de seletores seguida de uma lista de declarações propriedade:valor;.

  • Destaque de elementos combinados: junto ao seletor está um ícone de destino: clique nele para destacar todos os nós correspondentes da página a este seletor.
  • Declaração de sobrescrita: declarações que são sobrescritas por regras posteriores são cruzadas. Veja declarações de sobrescrita.
  • Exibição em cascata: junto a declarações de sobrescritas está uma 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.

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

Filtering rules

Starting in Firefox 40, 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.

New in Firefox 43

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.:

Starting in Firefox 43, if you enclose the search query in ticks, like this: `color`, the search is restricted to exact matches:

Displaying pseudo-elements

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

::after
::backdrop
(New in Firefox 46)
::before
::first-letter
::first-line
::selection
:-moz-color-swatch
:-moz-number-spin-box
:-moz-number-spin-down
:-moz-number-spin-up
:-moz-number-text
:-moz-number-wrapper
:-moz-placeholder
:-moz-progress-bar
:-moz-range-progress
:-moz-range-thumb
:-moz-range-track
:-moz-selection

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

From Firefox 41, there's a new button to the right of the filter box:

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

Although this button is new in Firefox 41, the feature existed in earlier versions of Firefox. It could - and still can - be accessed from the popup menu in the HTML view.

New in Firefox 43

Starting in Firefox 43, 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:

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.

From Firefox 41 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.

Get help for CSS properties

Starting in Firefox 40, 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.

New in Firefox 43

Starting in Firefox 43, 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:

Examine computed CSS

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:

Clicking the arrow next to the property name 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.

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.

Edit rules

If you click on a declaration or a selector in the Rules view you can edit it and see the results immediately. 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.

Starting in Firefox 48, 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.

From Firefox 44, edits that you make in the Rules view are reflected in the Style Editor, and vice versa.

Add rules

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.

Starting in Firefox 41, there's a button that enables you to do the same thing:

Copy rules

Starting in Firefox 41, there are extra context menu items in the Rules view to copy rules, and pieces of rules, to the clipboard:

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

Veja também

  • O Inspetor também inclui um número de ferramentas especializadas para trabalhar com funcionalidades particulares em CSS, tais como cores, fontes, e animações. To read about these see the list of how to guides.

Etiquetas do documento e colaboradores

 Colaboradores desta página: raphaellima8, jaimemaretoli, julianadfg
 Última atualização por: raphaellima8,