
CSS Tools: Validation, Browser Testing, Fonts, and References
12/10/2019
CSS Best Practices for Readable, Maintainable Code
12/10/2019
Learn to inspect elements in the browser so you can find CSS and HTML errors visually.
A web page often depends on several files working together. Bugs can range from a typo to a layout issue that is hard to spot in the source. Browsers such as Chrome, Firefox, and Safari include tools for inspecting a page while it runs.
These tools, known as DevTools, let you select an element and edit its HTML and CSS temporarily to see how changes affect the page.
Inspecting elements
The inspector lets you examine and modify HTML and CSS directly in the browser. The browser shows the result immediately, making it easier to diagnose layout and styling problems.
This lesson uses Chrome to demonstrate the basic workflow. The equivalent developer tools in other browsers work in a similar way.
Open DevTools in Google Chrome
Follow these steps to inspect an element:
- Open Google Chrome.
- Navigate to the page you want to inspect.
- Open DevTools:
- Right-click the element you want to inspect and choose Inspect.
- You can also press Ctrl+Shift+I on Windows or Linux, or Command+Option+I on macOS.
Inspect and edit HTML and CSS
- Explore the DOM: The Elements panel shows the page’s DOM. Hover over a node to highlight the corresponding box and see the space it occupies, including its padding and margins.
- Edit the HTML: Right-click a node to modify its HTML. Add, remove, or edit elements and attributes. These changes are local and disappear when you reload.
- Inspect the CSS: With an element selected, the Styles pane shows the rules that match it. Look in Computed for the value the browser uses.
- Change a rule: Click a property or value to edit it. Use the checkbox beside a declaration to toggle it and compare the results.
- Add a declaration: Click a blank area in a style rule and type a property name and value.
Example: The screenshot shows a heading containing a link with a background image. The inspector lets you measure the boxes, try a change to the code, and see the result immediately.

Changes made this way apply only to the current page in your browser. Update your project’s source files to make them permanent.