View and change CSS Stay organized with collections Save and categorize content based on your preferences.
Complete these interactive tutorials to learn the basics of viewing and changing a page's CSS usingChrome DevTools.
View an element's CSS
Right-click the
Inspect me!text below and selectInspect. TheElements panel of DevTools opens.Inspect me!
Observe the
Inspect me!element highlighted blue in theDOM Tree.
In theDOM Tree, find the value of the
data-messageattribute for theInspect me!element.Enter the attribute's value in the text box below.
In theElements >Styles tab, find the
alohaclass rule.TheStyles tab lists the CSS rules being applied to whatever element is selected in theDOM Tree, which should still be the
Inspect me!element.The
alohaclass is declaring a value forpadding. Enter this value and its unit without spaces in the text box below.
If you'd like to dock your DevTools window to the right of your viewport, like on the screenshot in step one, seeChange DevTools placement.
Add a CSS declaration to an element
Use theStyles tab when you want to change or add CSS declarations to an element.
Right-click the
Add a background color to me!text below and selectInspect.Add a background color to me!
Click
element.stylenear the top of theStyles tab.Type
background-colorand pressEnter.Type
honeydewand pressEnter. In theDOM tree, you can see that an inline style declaration was applied to the element.

Add a CSS class to an element
Use theStyles tab to see how an element looks when a CSS class is applied to or removed from anelement.
Right-click the
Add a class to me!element below and selectInspect.Add a class to me!
Click.cls. DevTools reveals a text box where you can add classes to the selected element.
Type
color_mein theAdd new class text box and then press Enter. A checkbox appears belowtheAdd new class text box, where you can toggle the class on and off. If theAdd a class to me!element had any other classes applied to it, you'd also be able to togglethem from here.

Add a pseudostate to a class
Use theStyles tab to apply a CSS pseudostate to an element.
Hover over the
Hover over me!text below. The background color changes.Hover over me!
Right-click the
Hover over me!text and selectInspect.In theStyles tab, click:hov.
Check the:hover checkbox. The background color changes like before, even though you're notactually hovering over the element.

For more information, seeToggle a pseudo-class.
Change the dimensions of an element
Use theBox Model interactive diagram in theStyles tab to change the width, height, padding, margin, or border length of an element.
Right-click the
Change my margin!element below and selectInspect.Change my margin!
To see theBox Model, click the
Show sidebar button in the action bar on theStyles tab.
In theBox Model diagram in theStyles tab, hover overpadding. The element's padding is highlighted in the viewport.

Double-click the left margin in theBox Model. The element currently doesn't have margins, so the
margin-lefthas a value of-.Type
100and pressEnter.
TheBox Model defaults to pixels, but it also accepts other values, such as25%, or10vw.
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-03-12 UTC.

