Get Started With Viewing And Changing CSS

Complete these interactive tutorials to learn the basics of viewing and changing the CSS for a page using Microsoft Edge DevTools.

Open CSS Examples

  1. Hold Control (Windows, Linux) or Command (macOS) and choose CSS Examples to open in a new window.

    CSS Examples

    Note

    If you want to dock your DevTools window to the right of your viewport (displayed in the following figure), choose Customize and control DevTools .... On the Customize and control DevTools drop-down menu, in the Dock side section, choose Dock to right.

View the CSS for an element

  1. Open CSS Examples.

  2. Hover on the Inspect Me! text, open the contextual menu (right-click), and choose Inspect.

    1. In DevTools, on the Elements panel, in the DOM Tree tab, the Inspect Me! element is highlighted.

      The inspected element is highlighted in the DOM Tree

    2. In the Inspect Me! element, find the value of the data-message attribute and copy it.

  3. On the page, in the Value of data-message: textbox, enter the value.

  4. Hover on the Inspect Me! text, open the contextual menu (right-click), and choose Inspect.

    1. In DevTools, on the Elements panel, select the Styles tab.

    2. In the Styles tab, the Inspect Me! element is highlighted.

    3. In the Inspect Me! element, find the aloha class rule.

      Note

      You see this rule because it is being applied to the Inspect Me! element.

    4. In the aloha class, find the value for the padding style and copy it.

      CSS classes being applied to the inspected element are highlighted in the Styles tab

  5. On the page, in the Value of padding: textbox, enter the value.

Add a CSS declaration to an element

Use the Styles tab when you want to change or add CSS declarations to an element.

Note

Complete the View the CSS for an element tutorial before doing this one.

  1. Open CSS Examples.

  2. Hover on the Add A Background Color To Me! text, open the contextual menu (right-click), and choose Inspect.

  3. Select element.style near the top of the Styles tab.

  4. Type background-color and select Enter.

  5. Type honeydew and select Enter. In the DOM Tree you should see that an inline style declaration was applied to the element.

    Adding a CSS declaration to the element using the Styles tab

Add a CSS class to an element

Use the Styles tab to see how an element looks when a CSS class is applied to or removed from an element.

Note

Complete the View the CSS for an element tutorial before doing this one.

  1. Open CSS Examples.

  2. Hover on the Add A Class To Me! text, open the contextual menu (right-click), and choose Inspect.

  3. Choose .cls. DevTools reveals a text box where you may add classes to the selected element.

  4. Type color_me in the Add new class text box and then select Enter. A checkbox appears below the Add new class text box, where you may toggle the class on and off. If the Add A Class To Me! element has any other classes applied to it, you are also able to toggle each from here.

    Applying the color_me class to the element

Add a pseudostate to a class

Use the Styles tab to permanently apply a CSS pseudostate to an element. DevTools supports :active, :focus, :hover, and :visited.

Note

Complete the View the CSS for an element tutorial before doing this one.

  1. Open CSS Examples.

  2. Hover over the Hover Over Me! text. The background color changes.

  3. Hover on the Hover Over Me! text, open the contextual menu (right-click), and choose Inspect.

  4. In the Styles tab, choose :hov.

  5. Check the :hover checkbox. The background color changes like before, even though you are not actually hovering over the element.

    Toggling the hover pseudostate on an element

Change the dimensions of an element

Use the Box Model interactive diagram in the Styles tab to change the width, height, padding, margin, or border length of an element.

Note

Complete the View the CSS for an element tutorial before doing this one.

  1. Open CSS Examples.

  2. Hover on the Change My Margin! text, open the contextual menu (right-click), and choose Inspect.

  3. In the Box Model diagram in the Styles tab, hover over padding. The padding of an element is highlighted in the viewport.

    Note

    Depending on the size of your DevTools window, you may need to scroll to the bottom of the Styles tab to see the Box Model.

  4. Double-click the left margin in the Box Model, which currently has a value of - meaning that the element does not have a left-margin.

  5. Type 100px and select Enter. The Box Model defaults to pixels, but it also accepts other values, such as 25%, or 10vw.

Debugging Media Queries

Media Queries are a way to make your web product react to changes in the configuration settings for each user. The most significant use case is to provide your product a different CSS layout depending on the dimensions of the viewport. Using separate layouts allows for a one-column layout for mobile devices and multi-column layouts when there is more screen estate available.

If you want to debug or test the Media Queries you defined in your CSS, use the following steps.

  1. Open the developer tools and select the Toggle device toolbar icon second on the top-left, or select Ctrl+Shift+M (Cmd+Shift+M on macOS).

    Opening the device toolbar

  2. With the device toolbar open, select the ... menu on the top-right and choose View Media Queries. You should see colored bars above the display of the page that represent the different media queries.

    Showing Media Queries in Device Toolbar

  3. Hover over the boundaries in the bars to see the values of the different media queries. Select each to resize the web page to match.

    Selecting Media Query from preview bar

  4. To debug media queries and open the CSS file in the Sources editor; hover on any of the bar segments, open the contextual menu (right-click), and select reveal in source code.

    Revealing Media Queries in Sources Editor

Getting in touch with the Microsoft Edge DevTools team

Use the following options to discuss the new features and changes in the post, or anything else related to DevTools.

  • Send your feedback using the Send Feedback icon or select Alt+Shift+I (Windows, Linux) or Option+Shift+I (macOS) in DevTools.
  • Tweet at @EdgeDevTools.
  • Submit a suggestion to The Web We Want.
  • File bugs on this article using the Feedback section.

The Send Feedback icon in the Microsoft Edge DevTools

Note

Portions of this page are modifications based on work created and shared by Google and used according to terms described in the Creative Commons Attribution 4.0 International License.
The original page is found here and is authored by Kayce Basques (Technical Writer, Chrome DevTools & Lighthouse).

Creative Commons License
This work is licensed under a Creative Commons Attribution 4.0 International License.