diff --git a/microsoft-edge/devtools/css/index.md b/microsoft-edge/devtools/css/index.md index b86d4181e6..de9ea8e3f1 100644 --- a/microsoft-edge/devtools/css/index.md +++ b/microsoft-edge/devtools/css/index.md @@ -31,7 +31,7 @@ To learn the basics of using DevTools to view and change the CSS for a page, fol 1. Open the [CSS Examples](https://microsoftedge.github.io/Demos/devtools-css-get-started/) demo page in a new window or tab. (To open a link in a new window or tab, right-click the link. Or, press and hold **Ctrl** (for Windows, Linux) or **Command** (for macOS) and then click the link.) - + 1. Right-click the `Inspect Me!` text, and then select **Inspect**. diff --git a/microsoft-edge/devtools/css/reference-images/at-font-palette-values-at-rule-rendered.png b/microsoft-edge/devtools/css/reference-images/at-font-palette-values-at-rule-rendered.png new file mode 100644 index 0000000000..75c927496f Binary files /dev/null and b/microsoft-edge/devtools/css/reference-images/at-font-palette-values-at-rule-rendered.png differ diff --git a/microsoft-edge/devtools/css/reference-images/at-position-try-at-rule-rendered.png b/microsoft-edge/devtools/css/reference-images/at-position-try-at-rule-rendered.png new file mode 100644 index 0000000000..e6c1911661 Binary files /dev/null and b/microsoft-edge/devtools/css/reference-images/at-position-try-at-rule-rendered.png differ diff --git a/microsoft-edge/devtools/css/reference-images/at-position-try-popovertarget.png b/microsoft-edge/devtools/css/reference-images/at-position-try-popovertarget.png new file mode 100644 index 0000000000..b84f1db4c6 Binary files /dev/null and b/microsoft-edge/devtools/css/reference-images/at-position-try-popovertarget.png differ diff --git a/microsoft-edge/devtools/css/reference-images/at-property-itemsize.png b/microsoft-edge/devtools/css/reference-images/at-property-itemsize.png new file mode 100644 index 0000000000..799fda1ac2 Binary files /dev/null and b/microsoft-edge/devtools/css/reference-images/at-property-itemsize.png differ diff --git a/microsoft-edge/devtools/css/reference-images/at-property-tooltip.png b/microsoft-edge/devtools/css/reference-images/at-property-tooltip.png new file mode 100644 index 0000000000..a0a6965714 Binary files /dev/null and b/microsoft-edge/devtools/css/reference-images/at-property-tooltip.png differ diff --git a/microsoft-edge/devtools/css/reference-images/at-scope-at-rule-rendered.png b/microsoft-edge/devtools/css/reference-images/at-scope-at-rule-rendered.png new file mode 100644 index 0000000000..f0d3d01a4d Binary files /dev/null and b/microsoft-edge/devtools/css/reference-images/at-scope-at-rule-rendered.png differ diff --git a/microsoft-edge/devtools/css/reference-images/cascade-layers.png b/microsoft-edge/devtools/css/reference-images/cascade-layers.png new file mode 100644 index 0000000000..93960b0599 Binary files /dev/null and b/microsoft-edge/devtools/css/reference-images/cascade-layers.png differ diff --git a/microsoft-edge/devtools/css/reference-images/change-length-values.png b/microsoft-edge/devtools/css/reference-images/change-length-values.png new file mode 100644 index 0000000000..ec67675661 Binary files /dev/null and b/microsoft-edge/devtools/css/reference-images/change-length-values.png differ diff --git a/microsoft-edge/devtools/css/reference-images/copy-css-dropdown-menu.png b/microsoft-edge/devtools/css/reference-images/copy-css-dropdown-menu.png new file mode 100644 index 0000000000..0ffc9c44a9 Binary files /dev/null and b/microsoft-edge/devtools/css/reference-images/copy-css-dropdown-menu.png differ diff --git a/microsoft-edge/devtools/css/reference-images/css-elements-computed-h1.png b/microsoft-edge/devtools/css/reference-images/css-elements-computed-h1.png index 415ed3d6a4..f9de78e97b 100644 Binary files a/microsoft-edge/devtools/css/reference-images/css-elements-computed-h1.png and b/microsoft-edge/devtools/css/reference-images/css-elements-computed-h1.png differ diff --git a/microsoft-edge/devtools/css/reference-images/css-elements-styles-h1-2.png b/microsoft-edge/devtools/css/reference-images/css-elements-styles-h1-2.png index cfc5d30c84..c37b2e397f 100644 Binary files a/microsoft-edge/devtools/css/reference-images/css-elements-styles-h1-2.png and b/microsoft-edge/devtools/css/reference-images/css-elements-styles-h1-2.png differ diff --git a/microsoft-edge/devtools/css/reference-images/css-elements-styles-h1-highlight.png b/microsoft-edge/devtools/css/reference-images/css-elements-styles-h1-highlight.png index 291575f51f..cf2d6a5023 100644 Binary files a/microsoft-edge/devtools/css/reference-images/css-elements-styles-h1-highlight.png and b/microsoft-edge/devtools/css/reference-images/css-elements-styles-h1-highlight.png differ diff --git a/microsoft-edge/devtools/css/reference-images/css-elements-styles-h1.png b/microsoft-edge/devtools/css/reference-images/css-elements-styles-h1.png index 8790e5a302..8e89f4fb5f 100644 Binary files a/microsoft-edge/devtools/css/reference-images/css-elements-styles-h1.png and b/microsoft-edge/devtools/css/reference-images/css-elements-styles-h1.png differ diff --git a/microsoft-edge/devtools/css/reference-images/css-elements-styles-insert-style-rule-below.png b/microsoft-edge/devtools/css/reference-images/css-elements-styles-insert-style-rule-below.png index 89a3b28b8b..5c11042a95 100644 Binary files a/microsoft-edge/devtools/css/reference-images/css-elements-styles-insert-style-rule-below.png and b/microsoft-edge/devtools/css/reference-images/css-elements-styles-insert-style-rule-below.png differ diff --git a/microsoft-edge/devtools/css/reference-images/dragging-control-point.png b/microsoft-edge/devtools/css/reference-images/dragging-control-point.png new file mode 100644 index 0000000000..549ca6123a Binary files /dev/null and b/microsoft-edge/devtools/css/reference-images/dragging-control-point.png differ diff --git a/microsoft-edge/devtools/css/reference-images/dragging-control-points.png b/microsoft-edge/devtools/css/reference-images/dragging-control-points.png new file mode 100644 index 0000000000..a6b10f132f Binary files /dev/null and b/microsoft-edge/devtools/css/reference-images/dragging-control-points.png differ diff --git a/microsoft-edge/devtools/css/reference-images/easing-editor.png b/microsoft-edge/devtools/css/reference-images/easing-editor.png index ccea54253a..29bc3def8b 100644 Binary files a/microsoft-edge/devtools/css/reference-images/easing-editor.png and b/microsoft-edge/devtools/css/reference-images/easing-editor.png differ diff --git a/microsoft-edge/devtools/css/reference-images/easing-function-ease-in-out.png b/microsoft-edge/devtools/css/reference-images/easing-function-ease-in-out.png new file mode 100644 index 0000000000..cde0d1285d Binary files /dev/null and b/microsoft-edge/devtools/css/reference-images/easing-function-ease-in-out.png differ diff --git a/microsoft-edge/devtools/css/reference-images/easing-function-ease-in.png b/microsoft-edge/devtools/css/reference-images/easing-function-ease-in.png new file mode 100644 index 0000000000..408d4e7ceb Binary files /dev/null and b/microsoft-edge/devtools/css/reference-images/easing-function-ease-in.png differ diff --git a/microsoft-edge/devtools/css/reference-images/easing-function-ease-out.png b/microsoft-edge/devtools/css/reference-images/easing-function-ease-out.png new file mode 100644 index 0000000000..d4591a4a7f Binary files /dev/null and b/microsoft-edge/devtools/css/reference-images/easing-function-ease-out.png differ diff --git a/microsoft-edge/devtools/css/reference-images/easing-function-linear.png b/microsoft-edge/devtools/css/reference-images/easing-function-linear.png new file mode 100644 index 0000000000..87e1bdaf7d Binary files /dev/null and b/microsoft-edge/devtools/css/reference-images/easing-function-linear.png differ diff --git a/microsoft-edge/devtools/css/reference-images/emulate-focused-page.png b/microsoft-edge/devtools/css/reference-images/emulate-focused-page.png new file mode 100644 index 0000000000..38cb292dfe Binary files /dev/null and b/microsoft-edge/devtools/css/reference-images/emulate-focused-page.png differ diff --git a/microsoft-edge/devtools/css/reference-images/insert-style-rule-below-icon.png b/microsoft-edge/devtools/css/reference-images/insert-style-rule-below-icon.png new file mode 100644 index 0000000000..6a7470ead5 Binary files /dev/null and b/microsoft-edge/devtools/css/reference-images/insert-style-rule-below-icon.png differ diff --git a/microsoft-edge/devtools/css/reference-images/new-style-rule-icon.png b/microsoft-edge/devtools/css/reference-images/new-style-rule-icon.png index c6bf915136..e224151821 100644 Binary files a/microsoft-edge/devtools/css/reference-images/new-style-rule-icon.png and b/microsoft-edge/devtools/css/reference-images/new-style-rule-icon.png differ diff --git a/microsoft-edge/devtools/css/reference-images/position-try-rule-in-styles-tab.png b/microsoft-edge/devtools/css/reference-images/position-try-rule-in-styles-tab.png new file mode 100644 index 0000000000..39d28fce5a Binary files /dev/null and b/microsoft-edge/devtools/css/reference-images/position-try-rule-in-styles-tab.png differ diff --git a/microsoft-edge/devtools/css/reference-images/scope-rule-in-styles-tab.png b/microsoft-edge/devtools/css/reference-images/scope-rule-in-styles-tab.png new file mode 100644 index 0000000000..f635b2c2af Binary files /dev/null and b/microsoft-edge/devtools/css/reference-images/scope-rule-in-styles-tab.png differ diff --git a/microsoft-edge/devtools/css/reference-images/the-tooltip-documentation.png b/microsoft-edge/devtools/css/reference-images/the-tooltip-documentation.png new file mode 100644 index 0000000000..4eb4606116 Binary files /dev/null and b/microsoft-edge/devtools/css/reference-images/the-tooltip-documentation.png differ diff --git a/microsoft-edge/devtools/css/reference-images/the-tooltip-specificity.png b/microsoft-edge/devtools/css/reference-images/the-tooltip-specificity.png new file mode 100644 index 0000000000..07708a980a Binary files /dev/null and b/microsoft-edge/devtools/css/reference-images/the-tooltip-specificity.png differ diff --git a/microsoft-edge/devtools/css/reference-images/the-value-a-custom-property.png b/microsoft-edge/devtools/css/reference-images/the-value-a-custom-property.png new file mode 100644 index 0000000000..cc610138b5 Binary files /dev/null and b/microsoft-edge/devtools/css/reference-images/the-value-a-custom-property.png differ diff --git a/microsoft-edge/devtools/css/reference-images/toggle-common-rendering-emulations-icon.png b/microsoft-edge/devtools/css/reference-images/toggle-common-rendering-emulations-icon.png new file mode 100644 index 0000000000..f7c5e53696 Binary files /dev/null and b/microsoft-edge/devtools/css/reference-images/toggle-common-rendering-emulations-icon.png differ diff --git a/microsoft-edge/devtools/css/reference-images/toggle-common-rendering-emulations.png b/microsoft-edge/devtools/css/reference-images/toggle-common-rendering-emulations.png new file mode 100644 index 0000000000..99b5a0d6e2 Binary files /dev/null and b/microsoft-edge/devtools/css/reference-images/toggle-common-rendering-emulations.png differ diff --git a/microsoft-edge/devtools/css/reference-images/toggle-css-layers-view-icon.png b/microsoft-edge/devtools/css/reference-images/toggle-css-layers-view-icon.png new file mode 100644 index 0000000000..68d0ddfd41 Binary files /dev/null and b/microsoft-edge/devtools/css/reference-images/toggle-css-layers-view-icon.png differ diff --git a/microsoft-edge/devtools/css/reference-images/various-links-highlighted.png b/microsoft-edge/devtools/css/reference-images/various-links-highlighted.png new file mode 100644 index 0000000000..d2056427a7 Binary files /dev/null and b/microsoft-edge/devtools/css/reference-images/various-links-highlighted.png differ diff --git a/microsoft-edge/devtools/css/reference-images/view-inherited-section.png b/microsoft-edge/devtools/css/reference-images/view-inherited-section.png new file mode 100644 index 0000000000..0e21652779 Binary files /dev/null and b/microsoft-edge/devtools/css/reference-images/view-inherited-section.png differ diff --git a/microsoft-edge/devtools/css/reference-images/view-pseudo-section.png b/microsoft-edge/devtools/css/reference-images/view-pseudo-section.png new file mode 100644 index 0000000000..9710f3bb8c Binary files /dev/null and b/microsoft-edge/devtools/css/reference-images/view-pseudo-section.png differ diff --git a/microsoft-edge/devtools/css/reference-images/view-supports-rules.png b/microsoft-edge/devtools/css/reference-images/view-supports-rules.png new file mode 100644 index 0000000000..ec791c0de6 Binary files /dev/null and b/microsoft-edge/devtools/css/reference-images/view-supports-rules.png differ diff --git a/microsoft-edge/devtools/css/reference.md b/microsoft-edge/devtools/css/reference.md index fd0747e8cb..947ae5119a 100644 --- a/microsoft-edge/devtools/css/reference.md +++ b/microsoft-edge/devtools/css/reference.md @@ -6,7 +6,7 @@ ms.author: msedgedevrel ms.topic: article ms.service: microsoft-edge ms.subservice: devtools -ms.date: 04/02/2026 +ms.date: 05/21/2026 --- - - Discover new workflows in the following comprehensive reference of Microsoft Edge DevTools features related to viewing and changing CSS. To learn the basics, see [Get started viewing and changing CSS](../css/index.md). @@ -33,33 +31,55 @@ To learn the basics, see [Get started viewing and changing CSS](../css/index.md) **Detailed contents:** * [Select an element](#select-an-element) * [View CSS](#view-css) + * [Navigate with links](#navigate-with-links) + * [View tooltips with CSS documentation, specificity, and custom property values](#view-tooltips-with-css-documentation-specificity-and-custom-property-values) + * [View CSS documentation](#view-css-documentation) + * [View selector specificity](#view-selector-specificity) + * [View the values of custom properties](#view-the-values-of-custom-properties) * [View the external stylesheet where a rule is defined](#view-the-external-stylesheet-where-a-rule-is-defined) + * [View invalid, overridden, inactive, and other CSS](#view-invalid-overridden-inactive-and-other-css) * [View only the CSS that is actually applied to an element](#view-only-the-css-that-is-actually-applied-to-an-element) * [View CSS properties in alphabetical order](#view-css-properties-in-alphabetical-order) * [View inherited CSS properties](#view-inherited-css-properties) + * [View CSS at-rules](#view-css-at-rules) + * [View `@property` at-rules](#view-property-at-rules) + * [View `@supports` at-rules](#view-supports-at-rules) + * [View `@scope` at-rules](#view-scope-at-rules) + * [View `@font-palette-values` at-rules](#view-font-palette-values-at-rules) + * [View `@position-try` at-rules](#view-position-try-at-rules) * [View an element's box model](#view-an-elements-box-model) * [Search and filter the CSS of an element](#search-and-filter-the-css-of-an-element) + * [Emulate a focused page](#emulate-a-focused-page) * [Toggle a pseudo-class](#toggle-a-pseudo-class) + * [View inherited highlight pseudo-elements](#view-inherited-highlight-pseudo-elements) + * [View cascade layers](#view-cascade-layers) * [View a page in print mode](#view-a-page-in-print-mode) * [View used and unused CSS with the Coverage tool](#view-used-and-unused-css-with-the-coverage-tool) * [Force print preview mode](#force-print-preview-mode) +* [Copy CSS](#copy-css) * [Change CSS](#change-css) * [Two ways to add a CSS declaration to an element](#two-ways-to-add-a-css-declaration-to-an-element) * [Adding an inline CSS declaration to an element](#adding-an-inline-css-declaration-to-an-element) * [Adding a CSS declaration to an existing style rule](#adding-a-css-declaration-to-an-existing-style-rule) * [Change a declaration name or value](#change-a-declaration-name-or-value) - * [Increment numerical declaration values](#increment-numerical-declaration-values) + * [Change enumerable values with keyboard shortcuts](#change-enumerable-values-with-keyboard-shortcuts) + * [Change length values](#change-length-values) * [Add a class to an element](#add-a-class-to-an-element) + * [Emulate light and dark theme preferences and enable automatic dark mode](#emulate-light-and-dark-theme-preferences-and-enable-automatic-dark-mode) * [Toggle a class](#toggle-a-class) * [Add a style rule](#add-a-style-rule) * [Select a stylesheet to add a rule to](#select-a-stylesheet-to-add-a-rule-to) - * [Add a style rule to a specific location](#add-a-style-rule-to-a-specific-location) + * [Add a style rule to a specific location in a stylesheet](#add-a-style-rule-to-a-specific-location-in-a-stylesheet) * [Toggle a declaration](#toggle-a-declaration) + * [Edit the `::view-transition` pseudo-elements during an animation](#edit-the-view-transition-pseudo-elements-during-an-animation) + * [Align grid items and their content with the Grid Editor](#align-grid-items-and-their-content-with-the-grid-editor) * [Change colors with the Color Picker](#change-colors-with-the-color-picker) * [Sample a color off the page with the Eyedropper](#sample-a-color-off-the-page-with-the-eyedropper) * [Change angle value with the Angle Clock](#change-angle-value-with-the-angle-clock) * [Change box and text shadows with the Shadow Editor](#change-box-and-text-shadows-with-the-shadow-editor) * [Edit animation and transition timings with the Easing Editor](#edit-animation-and-transition-timings-with-the-easing-editor) + * [Use presets to adjust timings](#use-presets-to-adjust-timings) + * [Configure custom timings](#configure-custom-timings) * [See also](#see-also) @@ -69,11 +89,14 @@ To learn the basics, see [Get started viewing and changing CSS](../css/index.md) The **Elements** tool in DevTools lets you view or change the CSS of one element at a time. The selected element is highlighted in the **DOM Tree**. The styles of the element are shown in the **Styles** pane. For a tutorial, see [View the CSS for an element](../css/index.md#view-the-css-for-an-element). -In the following figure, the `h1` element that is highlighted in the **DOM Tree** is the selected element. On the right, the styles of the element are shown in the **Styles** pane. On the left, the element is highlighted in the viewport, but only because the mouse is currently hovering over it in the **DOM Tree**: - ![An example of a selected element](./reference-images/css-elements-styles-h1.png) -There are many ways to select an element: +In the above figure: +* The `h1` element that is highlighted in the **DOM Tree** is the selected element. +* On the right, the styles of the element are shown in the **Styles** pane. +* On the left, the element is highlighted in the viewport, but only because the mouse is currently hovering over it in the **DOM Tree**: + +There are multiple ways to select an element: * In a rendered webpage, right-click a page element, and then click **Inspect**. @@ -92,29 +115,137 @@ Use the **Elements** > **Styles** and **Computed** tabs to view CSS rules and di - +#### Navigate with links +The **Styles** tab displays links in various places to various other places, including but not limited to: + +* Next to CSS rules, to stylesheets and CSS sources. Such links open the **Sources** tool. If the stylesheet is minified, see [Reformat a minified JavaScript file with pretty-print](../javascript/reference.md#reformat-a-minified-javascript-file-with-pretty-print) in _JavaScript debugging features_. + +* In the **Inherited from** sections, to parent elements. + +* In `var()` calls, to custom property declarations. See [Using CSS custom properties (variables)](https://developer.mozilla.org/docs/Web/CSS/Using_CSS_custom_properties) at MDN. + +* In `animation` shorthand properties, to `@keyframes`. + +* **Learn more** links in documentation tooltips. + +Links may be styled differently. If you're not sure if something is a link, try clicking it to find out. + +For example: + +1. Go to [To Do app](https://microsoftedge.github.io/Demos/demo-to-do/) in a new window or tab. + +1. Right-click white space above the string "Add a task", and then click **Inspect**. + + DevTools opens, with the **Elements** tool selected. + +1. Select the **Styles** tab. + + Various types of links are displayed: + + ![Various links highlighted](./reference-images/various-links-highlighted.png) + - +#### View tooltips with CSS documentation, specificity, and custom property values +In the **Elements** tool, the **Styles** tab shows tooltips with useful information when you hover over specific elements. + - +###### View CSS documentation +To display the description of a CSS property, in a tooltip: + +1. Go to a webpage, such as [To Do app](https://microsoftedge.github.io/Demos/demo-to-do/), in a new window or tab. + +1. Right-click white space above the string "Add a task", and then click **Inspect**. + + DevTools opens, with the **Elements** tool selected. + +1. Select the **Styles** tab. + +1. Hover over a CSS property name, such as `padding:`. + + A tooltip is displayed: + + ![The tooltip with documentation on a CSS property](./reference-images/the-tooltip-documentation.png) + + DevTools pulls the descriptions for tooltips from the [VS Code Custom Data](https://github.com/microsoft/vscode-custom-data) repo. + +1. In the tooltip, click the **Learn more** link. + + The CSS reference page for the property at MDN is displayed, such as [`padding` CSS property](https://developer.mozilla.org/docs/Web/CSS/Reference/Properties/padding). + + +To turn the CSS tooltips off: + +* In the tooltip, select the **Don't show** checkbox. + + +To turn CSS tooltips on again: + +1. In DevTools, select **Customize and control DevTools**, and then select **Settings**. + +1. In the outline on the left, select **Preferences**, and then scroll down to the **Elements** section. + +1. Select the **Show CSS documentation tooltip** checkbox. + - +###### View selector specificity +Hover over a CSS selector, to display a tooltip that shows the selector's specificity weight, such as: **Specificity: (0,0,1)**: + +For example: + +1. Go to a webpage, such as [To Do app](https://microsoftedge.github.io/Demos/demo-to-do/), in a new window or tab. + +1. Right-click the webpage, and then click **Inspect**. + + DevTools opens, with the **Elements** tool selected. + +1. In the DOM tree, select the `` element. + +1. In the **Styles** tab, hover over the `body` CSS selector. + + A tooltip is displayed, showing **Specificity: (0,0,1)**: + + ![The tooltip with specificity weight of a matched selector](./reference-images/the-tooltip-specificity.png) + +See also: +* [Specificity](https://developer.mozilla.org/docs/Web/CSS/Specificity) - MDN. + - +###### View the values of custom properties +Hover over a `var(--custom-property)` function to see the value of the custom property in a tooltip. + +For example: + +1. Go to a webpage, such as [To Do app](https://microsoftedge.github.io/Demos/demo-to-do/), in a new window or tab. + +1. Right-click the webpage, and then click **Inspect**. + + DevTools opens, with the **Elements** tool selected. + +1. In the DOM tree, select the `` element. + +1. In the **Styles** tab, in the `body` CSS rule, hover over `--spacing`. + + The value `.3rem` is displayed in a tooltip: + + ![The value of a custom property in a tooltip](./reference-images/the-value-a-custom-property.png) + +See also: +* [Custom properties (`--*`): CSS variables](https://developer.mozilla.org/docs/Web/CSS/--*) - MDN. + #### View the external stylesheet where a rule is defined @@ -122,19 +253,25 @@ Use the **Elements** > **Styles** and **Computed** tabs to view CSS rules and di In the **Styles** pane, click the link next to a CSS rule to open the external stylesheet that defines the rule. The stylesheet opens in the **Editor** pane of the **Sources** tool. -If the stylesheet is minified, click the **Format** (![Format](./reference-images/format-icon.png)) button, at the bottom of the **Editor** pane. For more information, see [Reformat a minified JavaScript file with pretty-print](../javascript/reference.md#reformat-a-minified-javascript-file-with-pretty-print). - -In the following figure, after you click -`https://learn.microsoft.com/_themes/docs.theme/master/en-us/_themes/styles/b66bc881.site-ltr.css:2` you are taken to line 2 of -`https://learn.microsoft.com/_themes/docs.theme/master/_themes/styles/b66bc881.site-ltr.css`, where the `.content h1:first-of-type` CSS rule is defined. +If the stylesheet is minified, click the **Format** (![Format](./reference-images/format-icon.png)) button, at the bottom of the **Editor** pane. For more information, see [Reformat a minified JavaScript file with pretty-print](../javascript/reference.md#reformat-a-minified-javascript-file-with-pretty-print) in _JavaScript debugging features_. ![Viewing the stylesheet where a rule is defined](./reference-images/css-elements-styles-h1-highlight.png) +In the above figure, after you click `to-do-styles.css:5`, you are taken to line 5 of `to-do-styles.css`, where the `h1` CSS rule is defined. + - +#### View invalid, overridden, inactive, and other CSS +The **Styles** tab recognizes many kinds of CSS issues and highlights them in different ways. + + + #### View only the CSS that is actually applied to an element @@ -142,77 +279,251 @@ In the following figure, after you click The **Styles** pane shows you all of the rules that apply to an element, including declarations that have been overridden. When you aren't interested in overridden declarations, use the **Computed** pane to view only the CSS that is actually being applied to an element. -1. [Select an element](#select-an-element). +For example: -1. Go to the **Computed** pane in the **Elements** tool. +1. Go to a webpage, such as [To Do app](https://microsoftedge.github.io/Demos/demo-to-do/), in a new window or tab. - On a wide DevTools window, the **Computed** pane doesn't exist. The contents of the **Computed** pane are shown on the **Styles** pane. +1. Right-click the heading **My tasks**, and then click **Inspect**. - Inherited properties are opaque. + DevTools opens, with the **Elements** tool selected, with the `

` element selected in the DOM tree. -1. To display all inherited values, select the **Show All** checkbox. +1. In the **Elements** tool, select the **Computed** tab. - In the following figure, the **Computed** pane shows the CSS properties being applied to the currently selected `h1` element: + The CSS properties that are applied to the selected element are displayed: ![The Computed panel](./reference-images/css-elements-computed-h1.png) + A property name and value in italics indicates a value that's calculated at runtime. + +1. To display all properties, select the **Show all** checkbox. + + + #### View CSS properties in alphabetical order -Use the **Computed** pane. See [View only the CSS that is actually applied to an element](#view-only-the-css-that-is-actually-applied-to-an-element). +Use the **Computed** pane. See [View only the CSS that is actually applied to an element](#view-only-the-css-that-is-actually-applied-to-an-element), above. #### View inherited CSS properties -Check the **Show All** checkbox in the **Computed** pane. See [View only the CSS that is actually applied to an element](#view-only-the-css-that-is-actually-applied-to-an-element). +Check the **Show All** checkbox in the **Computed** pane. See [View only the CSS that is actually applied to an element](#view-only-the-css-that-is-actually-applied-to-an-element), above. - +#### View CSS at-rules +At-rules are CSS statements that let you control CSS behavior. + +In the **Elements** tool, the **Styles** tab shows the following at-rules in dedicated sections: + +* `@property` - see [View `@property` at-rules](#view-property-at-rules), below. +* `@supports` - see [View `@supports` at-rules](#view-supports-at-rules), below. +* `@scope` - see [View `@scope` at-rules](#view-scope-at-rules), below. +* `@font-palette-values` - see [View `@font-palette-values` at-rules](#view-font-palette-values-at-rules), below. +* `@position-try` - see [View `@position-try` at-rules](#view-position-try-at-rules), below. + - +###### View `@property` at-rules +The `@property` CSS at-rule lets you define CSS custom properties of specific types in a stylesheet. + +Hover over the name of such a property in the **Styles** tab, to see a tooltip that contains: +* The property's value, such as `20%`. +* The property's descriptors, such as: `initial value: 40%` +* A **View registered property** link to its registration in the collapsible `@property` section at the bottom of the **Styles** tab. + +For example: + +1. Go to a page that uses the `@property` at-rule, such as [View `@property` at-rules](https://microsoftedge.github.io/Demos/at-rules-property/), in a new window or tab. + +1. Right-click the **Item three** paragraph, and then click **Inspect**. + + DevTools opens, with the **Elements** tool selected. + +1. In the **Styles** tab, hover over that `var(--itemSize)` function: + + ![Tooltip for the at-property CSS at-rule](./reference-images/at-property-tooltip.png) + + The tooltip contains: + * The property's value, such as `100px`. + * The property's descriptors, such as initial value. + * A **View registered property** link. + +1. Click the **View registered property** link. + + The expanded **@property** section is displayed, further down in the **Styles** tab: + + ![--itemSize in the at-property section](./reference-images/at-property-itemsize.png) + +To edit an `@property` rule, double-click its name or value. See [Change a declaration name or value](#change-a-declaration-name-or-value), below. + +See also: +* [@property: giving superpowers to CSS variables](https://web.dev/articles/at-property) at Web.dev. +* [Custom properties (`--*`): CSS variables](https://developer.mozilla.org/docs/Web/CSS/Reference/Properties/--*) at MDN. + - +###### View `@supports` at-rules +The **Styles** tab shows you the `@supports` CSS at-rules, if they are applied to an element. + +For example, to view the `@supports` rule: + +1. In a new window or tab, go to a page that uses the `@supports` at-rule, such as [View `@supports` at-rules](https://microsoftedge.github.io/Demos/at-rules-supports/). + +1. Right-click "I support CIE LAB color space!", and then select **Inspect**. + + DevTools opens. In the **Elements** tool, in the DOM tree, the `
` element is selected. In the **Styles** tab, `@supports` CSS declarations are listed: + + ![Result of HTML for the at-supports at-rule](./reference-images/view-supports-rules.png) + +* If your browser supports the `lab()` function, the element is green. + +* If your browser doesn't support the `lab()` function, the element is purple. + +To see which browser versions support the CIE LAB color space, [search Caniuse.com for "lab"](https://caniuse.com/?search=lab). + - +###### View `@scope` at-rules +The **Styles** tab displays CSS `@scope` at-rules if they are applied to an element. + +The `@scope` at-rules allow you to scope CSS styles; that is, explicitly apply styles to specific elements. See [`@scope` CSS at-rule](https://developer.mozilla.org/docs/Web/CSS/Reference/At-rules/@scope) at MDN. + +To view the `@scope` rule: + +1. In a new window or tab, go to a page that uses the `@scope` at-rule, such as the [View `@scope` at-rules](https://microsoftedge.github.io/Demos/at-rules-scope/) demo: + + ![Result of HTML & CSS for the at-scope at-rule](./reference-images/at-scope-at-rule-rendered.png) + +1. Right-click "I'm the text that lives on a card", and then select **Inspect**. + + DevTools opens, with the **Elements** tool selected. + +1. Select the **Styles** tab. + +1. Examine the `@scope` rule: + + ![The at-scope rule in the Styles tab](./reference-images/scope-rule-in-styles-tab.png) + + In this example, the `@scope` rule (background color = plum) overrides the global CSS `background-color` declaration (aquamarine), for any `

` element that's inside an element (such as a `

`) that has a `card` class. + + To edit the `@scope` rule, you double-click in the rule: + +1. In the **Styles** tab, double-click **plum**, press **Delete**, and then select **beige**. + + The text in the card in the demo webpage changes from plum background to beige background. + - +###### View `@font-palette-values` at-rules +The [@font-palette-values CSS at-rule](https://developer.mozilla.org/docs/Web/CSS/@font-palette-values) lets you customize (override) the default values of the `font-palette` property. In the **Elements** tool, the **Styles** tab shows this at-rule in a dedicated section. + +To view the `@font-palette-values` CSS rule: + +1. In a new window or tab, go to a page that uses the `@font-palette-values` at-rule, such as the [View `@font-palette-values` at-rules](https://microsoftedge.github.io/Demos/at-rules-font-palette-values/) demo. + +1. Right-click "new colors", and then select **Inspect**. + + DevTools opens, with the **Elements** tool selected. + +1. In the **Styles** tab, find the `@font-palette-values` CSS rule: + + ![The at-font-palette-values rule in the Styles tab](./reference-images/at-font-palette-values-at-rule-rendered.png) + + In this example, the `--New` font palette values override the default values of the colored font. + + To edit a custom value, double-click it, as follows: + +1. In the `@font-palette-values` CSS rule, in the `override-colors` property, double-click `0 gold, 1 red`, and enter `0 blue, 1 red`. + + In the inspected webpage, "new colors" is now rendered as blue and red. + - +###### View `@position-try` at-rules + + +The `@position-try` CSS rule along with the `position-try-fallbacks` property lets you define alternative anchor positions for elements. + +In the **Elements** tool, the **Styles** tab resolves and links the following: + +* The `position-try-fallbacks` property values (or `position-try-options` property values) link to a dedicated `@position-try --name` CSS rule section. + +* The `position-anchor` property values and `anchor()` arguments link to the corresponding elements that have `popovertarget` attributes. + +For example, inspect the `position-try-fallbacks` values and `@position-try` CSS rules, as follows: + +1. In a new window or tab, go to a page that uses the `position-try-fallbacks` values and `@position-try` at-rule, such as the [View `@position-try` at-rules](https://microsoftedge.github.io/Demos/at-rules-position-try/) demo. + +1. In the rendered webpage, open the submenu; that is, click **YOUR ACCOUNT**, and then click **STOREFRONT**. + + The submenu is displayed, showing a list of commands: **LISTINGS**, **SPECIAL OFFERS**, **SIGN OUT**. + +1. In the submenu, right-click above **LISTINGS**, and then select **Inspect**. + + DevTools opens, with the **Elements** tool selected. The submenu element `