Skip to content

Commit 39a8895

Browse files
Complete the CSS Overview tool docs (#2154)
* Improving the CSS Overview docs (part 1) * Improving the CSS Overview docs (part 2) * Updating ms.date * Changed title to address review comment
1 parent 9e86ee7 commit 39a8895

14 files changed

Lines changed: 140 additions & 28 deletions
Lines changed: 139 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,161 @@
11
---
2-
title: CSS Overview tool
2+
title: Optimize CSS styles with the CSS Overview tool
33
description: The CSS Overview tool in Microsoft Edge DevTools.
44
author: MSEdgeTeam
55
ms.author: msedgedevrel
66
ms.topic: conceptual
77
ms.prod: microsoft-edge
88
ms.technology: devtools
9-
ms.date: 02/15/2022
9+
ms.date: 09/07/2022
1010
---
11-
<!-- Copyright Kayce Basques
11+
# Optimize CSS styles with the CSS Overview tool
1212

13-
Licensed under the Apache License, Version 2.0 (the "License");
14-
you may not use this file except in compliance with the License.
15-
You may obtain a copy of the License at
13+
The **CSS Overview** tool captures an overview of the CSS code used on a webpage and displays a report about the colors, fonts, and media-queries used. The tool also identifies potential color contrast issues and unused CSS declarations issues.
1614

17-
https://www.apache.org/licenses/LICENSE-2.0
1815

19-
Unless required by applicable law or agreed to in writing, software
20-
distributed under the License is distributed on an "AS IS" BASIS,
21-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22-
See the License for the specific language governing permissions and
23-
limitations under the License. -->
24-
# CSS Overview tool
16+
<!-- ====================================================================== -->
17+
## Open the CSS Overview tool
18+
19+
To open the **CSS Overview** tool:
20+
21+
1. Navigate to the [TODO list demo app](https://microsoftedge.github.io/Demos/demo-to-do/) in Microsoft Edge, or to your own webpage.
22+
23+
1. Open DevTools by pressing `F12` or `Ctrl`+`Shift`+`I` (Windows, Linux) or `Command`+`Option`+`I` (macOS).
24+
25+
1. In the main toolbar, click **More Tools** and select **CSS Overview** from the list.
26+
27+
![Microsoft Edge, with the TODO list demo app, and DevTools next to it, showing the list of tools from the More Tools button](images/css-overview-tool-open.png)
28+
29+
1. The **CSS Overview** tool opens and shows a welcome screen.
30+
31+
![Microsoft Edge, with the TODO list demo app, and DevTools next to it, showing the CSS Overview welcome screen](images/css-overview-tool-welcome.png)
32+
33+
34+
<!-- ====================================================================== -->
35+
## Capture a CSS overview report
36+
37+
Start using the tool by capturing a new report. Click **Capture overview**, the overview report appears.
38+
39+
![Microsoft Edge, with the TODO list demo app, and DevTools next to it, showing the CSS Overview report for that site](images/css-overview-tool-report.png)
40+
41+
If you make changes to your webpage and want to view a new report, click **Clear overview** and then capture a new overview.
42+
43+
![Microsoft Edge, with the TODO list demo app, and DevTools next to it, showing a CSS Overview report with the Clear overview button at the top](images/css-overview-tool-clear.png)
44+
45+
46+
<!-- ====================================================================== -->
47+
## Understand the report
48+
49+
The overview report contains information organized in several sections:
50+
51+
* **Summary**: statistics about key CSS rules, selectors, and media queries on the page.
52+
* **Colors**: colors used on the page.
53+
* **Font info**: list of fonts on the page.
54+
* **Unused declarations**: list of unused CSS declarations.
55+
* **Media queries**: list of media queries.
56+
57+
To review the above sections, scroll through the report, or use the table of content sidebar.
58+
59+
![Microsoft Edge, with the TODO list demo app and DevTools, showing the table of content and scrollbar in the CSS Overview report](images/css-overview-tool-scroll.png)
60+
61+
### Summary
62+
63+
The **Summary** section is useful to get a quick overview of your CSS code. It provides the number of external and inline stylesheets, the number of CSS rules, the number of selectors and their various types, and the number of media queries.
64+
65+
This can be used to assess the volume and consistency of your CSS codebase on a given webpage. For example, if you decided to only use class selectors, the **Summary** section will make it quick to detect other types of selectors like ID or attribute.
66+
67+
### Colors
68+
69+
The **Colors** section lists all the colors used on the webpage, and groups them by background, text, fill, and border categories.
70+
71+
This can be useful to discover cases when several similar colors are used instead of one common color. CSS custom properties (also known as CSS variables) can be used to avoid repeating colors throughout a CSS file and therefore avoid this problem. Learn more about CSS variables on [MDN](https://developer.mozilla.org/en-US/docs/Web/CSS/--*)).
72+
73+
The **Colors** section also contains a list of color contrast issues on the page. To learn more, see [View elements with color contrast issues](#view-elements-with-color-contrast-issues).
74+
75+
### Font info
2576

26-
<!-- the what's new entry is:
27-
https://docs.microsoft.com/microsoft-edge/devtools-guide-chromium/whats-new/2020/10/devtools#view-and-fix-color-contrast-issues-in-the-css-overview-tool
28-
# What's New in DevTools (Microsoft Edge 87)
29-
### View and fix color contrast issues in the CSS Overview tool -->
77+
The **Font info** section lists all the font families used on the webpage and provides details about which sizes, weights, and line heights are used for each.
3078

31-
The **CSS Overview** tool displays a summary of CSS-related information about the webpage. This tool lists the colors, fonts, and media queries the webpage uses. The tool also lists the elements on your page that have color contrast issues, and the unused CSS declarations. The [CSS Overview Accessible Colors Demo](https://css-overview-accessible-colors-demo.glitch.me) page has an example of a color contrast issue.
79+
When designing a webpage, using consistent typography settings can help reach a more aesthetically-pleasing result. The **Font info** section can be useful to detect when too many different fonts or font styles are used.
3280

33-
To view a list of elements that have a color contrast issue, on **Contrast issues**, click **Text**.
81+
Each font in the **Font info** section contains links to the DOM elements they apply to. To reveal the elements a given font applies to:
3482

35-
To open the element in the **Elements** tool, click an element in the list. To help fix contrast issues, DevTools [automatically provides color suggestions](../whats-new/2020/08/devtools.md#accessible-color-suggestion-in-the-styles-pane).
83+
1. On the overview report, click **Font info** in the sidebar to scroll to the relevant section of the report.
3684

85+
1. Find the font family and the size, weight, or line-height you are interested in.
3786

38-
For updates on this feature in the Chromium open-source project, see Issue [#1120316](https://crbug.com/1120316).
87+
1. Click the **X occurrences** link next to it to reveal the list of elements.
3988

40-
![Low color contrast issues.](../whats-new/media/2020/10/css-overview.msft.png)
89+
1. Move your mouse over the elements in the list to highlight them in the rendered page.
90+
91+
![Microsoft Edge, with the TODO list demo app and DevTools, showing the list of elements for a given font-size, and a highlighted element on hover](images/css-overview-tool-font-element.png)
92+
93+
1. Click an element to automatically open the **Elements** tool with that element selected.
94+
95+
![Microsoft Edge, with the TODO list demo app and DevTools, showing Elements tool, with the right node selected](images/css-overview-tool-elements-tool.png)
96+
97+
### Unused declarations
98+
99+
The **Unused declarations** section lists some of the CSS declarations that don't have an effect on their target elements.
100+
101+
CSS declarations are key/value pairs such as `top: 42px`. CSS declarations are contained in CSS rules, and rules target specific elements on the webpage. Depending on other styles applied to an element, a CSS declaration may not have any effect.
102+
103+
As an example, the `top: 42px` declaration will not have any effect if the element it targets is not positioned with `position: absolute` or `position: relative` for example.
104+
105+
These cases may be hard to find and the **Unused declarations** section helps by listing some of them. Note that not all possible cases are listed. For now, the following cases are reported:
106+
107+
<!-- This part of the tool will get refactored when the Authoring Hints feature is completed.
108+
So this list will need to be updated then. -->
109+
* When the `top`, `right`, `bottom`, or `left` properties are used on statically positioned elements.
110+
* When the `width` or `height` properties are used on inline elements.
111+
* When the `vertical-align` property is used on elements that are not inline or table cells.
112+
113+
### Media queries
114+
115+
The **Media queries** section lists the CSS media queries found on the webpage.
116+
117+
CSS media queries can be used to apply specific styles depending on the media type (for example `print` or `screen`) or depending on the viewport size. This is often used to make webpages respond to the available space.
118+
119+
When a CSS codebase becomes complex, keeping track of all the CSS media queries can be hard. The **Media queries** section makes this easier. Each media query in the section also contains a link to the CSS file it's defined in. To reveal that file:
120+
121+
1. On the overview report, click **Media queries** in the sidebar to scroll to the relevant section of the report.
122+
123+
1. In the report, find the media query you are interested in.
124+
125+
1. Click the **X occurrences** link next to it to reveal the corresponding files.
126+
127+
![Microsoft Edge, with the TODO list demo app and DevTools, showing the media queries section of the Overview tool, and the list of files that contain a given media query](images/css-overview-tool-media-query.png)
128+
129+
1. Click one of the files to automatically open the **Sources** tool with that file opened.
130+
131+
![Microsoft Edge, with the TODO list demo app and DevTools, showing the Sources tool, with the file that contains a media query opened, at the right line](images/css-overview-tool-sources-tool.png)
41132

42133

43134
<!-- ====================================================================== -->
44-
> [!NOTE]
45-
> Portions of this page are modifications based on work created and [shared by Google](https://developers.google.com/terms/site-policies) and used according to terms described in the [Creative Commons Attribution 4.0 International License](https://creativecommons.org/licenses/by/4.0).
46-
> The original page is found [here](https://developer.chrome.com/docs/devtools/css-overview/) and is authored by [Jecelyn Yeen](https://developers.google.com/web/resources/contributors#jecelyn-yeen) (Developer advocate, Chrome DevTools).
135+
## View elements with color contrast issues
136+
137+
The **Colors** section of the overview report can also be used to find color contrast issues on a webpage. If the current webpage contains elements where the contrast between the font color and the background color is insufficient, the **Contrast issues** sub-section will be displayed.
138+
139+
To find color contrast issues:
140+
141+
1. Navigate to the [Animal Shelter](https://microsoftedge.github.io/Demos/devtools-a11y-testing/) demo website, which has color contrast issues, in Microsoft Edge. Or navigate to your own website.
142+
143+
1. Open DevTools by pressing `Ctrl`+`Shift`+`I` (Windows, Linux) or `Command`+`Option`+`I` (macOS).
144+
145+
1. In the main toolbar, click **More Tools** and select **CSS Overview** from the list.
146+
147+
1. In the **CSS Overview** tool, click **Capture overview** and then click **Colors** in the overview report sidebar.
148+
149+
1. Scroll down to the **Contrast issues** sub-section to view all issues.
150+
151+
![Microsoft Edge, with the TODO list demo app and DevTools, showing a list of contrast issues in the CSS Overview report](images/css-overview-tool-contrast-issues.png)
152+
153+
1. To view the elements that have a particular color contrast issue, choose the issue you want to fix and click **Text**. The corresponding elements are listed.
154+
155+
![Microsoft Edge, with the TODO list demo app and DevTools, showing a list of elements with a color contrast issue](images/css-overview-tool-contrast-issues-elements.png)
156+
157+
1. To open the corresponding element in the **Elements** tool, click an element in the list.
158+
159+
![Microsoft Edge, with the TODO list demo app and DevTools, showing the Elements tool, with the color-contrast issue element selected](images/css-overview-tool-contrast-issues-elements-tool.png)
47160

48-
[![Creative Commons License.](../../media/cc-logo/88x31.png)](https://creativecommons.org/licenses/by/4.0)
49-
This work is licensed under a [Creative Commons Attribution 4.0 International License](https://creativecommons.org/licenses/by/4.0).
161+
To help fix contrast issues, check out the [Text contrast](../accessibility/reference.md#text-contrast) section of the accessibility-testing DevTools features.
128 KB
Loading
232 KB
Loading
197 KB
Loading
184 KB
Loading
219 KB
Loading
170 KB
Loading
135 KB
Loading
191 KB
Loading
128 KB
Loading

0 commit comments

Comments
 (0)