Page Inspector

  • Revision slug: Tools/Page_Inspector
  • Revision title: Page Inspector
  • Revision id: 435691
  • Created:
  • Creator: wbamberg
  • Is current revision? No
  • Comment

Revision Content

Use the Inspector to examine the structure and layout of a page.

Opening the Inspector

To open the Inspector, choose the "Inspector" option from the "Web Developer" menu (which is a submenu in the "Tools" menu on the Mac), or press Ctrl-Shift-I (Cmd-Option-I on the Mac OS X and Linux).

The DevTools Window will appear at the bottom of the browser window, with the Inspector activated. Now, as you move your mouse around the page, the element under your mouse is highlighted with a dotted border and an annotation displays its HTML tag. At the same time, its HTML definition is displayed, in context, in the Inspector's left-hand pane.

Selecting Elements

Clicking on the element selects it: once it is selected, the Inspector's display is locked on this element, so you can move the mouse around without the Inspector switching to a new element. You'll see information about the element's style in the right-hand pane of the Inspector, and the annotation for the element displays some extra information and gets a button on the side, that you can use to unselect the element:

Anatomy of the Inspector

The main window of the Inspector is split into two halves: the left-hand half displays information about the page's HTML, while the right-hand half displays information about the page's CSS:

HTML pane

The HTML pane shows you the page's HTML as a collapsible tree. The start and end tags for the selected element are highlighted with a grey background.

You can edit the HTML - tags, attributes, and content - directly in this pane: click the element you want to edit, change it, and press Enter to see the changes reflected immediately.

Context-clicking an element displays a context menu which enables you to:

  • copy the inner or outer HTML for the element
  • copy a CSS selector that would uniquely identify this element
  • delete that element
  • set the :hover, :focus, and :active CSS pseudo-classes

For example, go to http://example.iana.org/:

 

 

Above this pane is a dedicated toolbar split into three sections:

  • Select element: if you click this button, you can then select a different element by mousing around in the browser window.
  • HTML breadcrumbs: this shows the complete hierarchy through the document for the branch containing the selected element.

 

 

 

 mousing around in the browser window. Clicking it while no element is currently selected will select the element currently pointed at by the mouse.

Breadcrumbs: element hierarchy (arrow keys)
The majority of the toolbar is occupied by the breadcrumbs bar. This bar shows the hierarchy of all the nested elements, with its parent elements to the left and child elements to the right. Each element's element and CSS style and/or class is shown. If the information is cut off, mousing over the element's entry in the toolbar presents a tooltip with the complete description. If you click and hold on one of the elements in the bar, a popup menu appears that lets you select one of that element's siblings. Clicking the small arrow icons at the left and right ends of the bar will scroll the bar if it's wider than the available space; you can also use the arrow keys to navigate the element hierarchy bar.
3D View button (Ctrl-W) {{ fx_minversion_inline("11.0") }}
Toggles the 3D view on and off. This button is only available if your system supports WebGL, but if available, clicking it lets you view the DOM hierarchy of your page as a 3D representation. If you don't see the 3D button, it is possible that your graphics driver needs to be updated. See the blocklisted drivers page for more information.
HTML button (Ctrl-H)
The HTML button toggles on and off the HTML panel, which provides a view at the HTML that created the selected element.
Style button (Ctrl-S)
The Style button toggles on and off the Style panel, which shows the CSS responsible for styling the selected element.

Keyboard shortcuts

There are a number of handy shortcuts you can use while inspecting your page.

Shortcut Description
Moves to the parent of the selected node.
Moves to the first child of the selected node.
Moves to the previous sibling of the selected node.
Moves to the next sibling of the selected node.
ESC Closes the Page Inspector.
Return/Enter Locks and unlocks the currently highlighted element as the selected element to inspect.

Using the Page Inspector with the Web Console

You can, of course, use the Web Console at the same time as the Page Inspector. In fact, you even have a bonus feature! The element that's currently selected in the Page Inspector, if any, can be referenced in JavaScript in the Web Console using the variable $0.

web-console.png

See also

{{ languages( { "ja": "ja/Tools/Page_Inspector"} ) }}

Revision Source

<p>Use the Inspector to examine the structure and layout of a page.</p>
<h2 id="Opening_the_Inspector">Opening the Inspector</h2>
<p>To open the Inspector, choose the "Inspector" option from the "Web Developer" menu (which is a submenu in the "Tools" menu on the Mac), or press Ctrl-Shift-I (Cmd-Option-I on the Mac OS X and Linux).</p>
<p>The <a href="/en-US/docs/Tools/DevTools_Window" title="/en-US/docs/Tools/DevTools_Window">DevTools Window</a> will appear at the bottom of the browser window, with the Inspector activated. Now, as you move your mouse around the page, the element under your mouse is highlighted with a dotted border and an annotation displays its HTML tag. At the same time, its HTML definition is displayed, in context, in the Inspector's left-hand pane.</p>
<p><img alt="" src="https://mdn.mozillademos.org/files/5323/inspector-no-element-selected.png" style="width: 915px; height: 958px; display: block; margin-left: auto; margin-right: auto;" /></p>
<h2 id="Selecting_Elements">Selecting Elements</h2>
<p>Clicking on the element selects it: once it is selected, the Inspector's display is locked on this element, so you can move the mouse around without the Inspector switching to a new element. You'll see information about the element's style in the right-hand pane of the Inspector, and the annotation for the element displays some extra information and gets a button on the side, that you can use to unselect the element:</p>
<p><img alt="" src="https://mdn.mozillademos.org/files/5327/inspector-element-selected.png" style="width: 915px; height: 958px; display: block; margin-left: auto; margin-right: auto;" /></p>
<h2 id="Anatomy_of_the_Inspector">Anatomy of the Inspector</h2>
<p>The main window of the Inspector is split into two halves: the left-hand half displays information about the page's HTML, while the right-hand half displays information about the page's CSS:</p>
<h3 id="HTML_pane">HTML pane</h3>
<p>The HTML pane shows you the page's HTML as a collapsible tree. The start and end tags for the selected element are highlighted with a grey background.</p>
<p>You can edit the HTML - tags, attributes, and content - directly in this pane: click the element you want to edit, change it, and press Enter to see the changes reflected immediately.</p>
<p>Context-clicking an element displays a context menu which enables you to:</p>
<ul>
  <li>copy the inner or outer HTML for the element</li>
  <li>copy a CSS selector that would uniquely identify this element</li>
  <li>delete that element</li>
  <li>set the <a href="/en-US/docs/Web/CSS/:hover" title="/en-US/docs/Web/CSS/:hover">:hover</a>, <a href="/en-US/docs/Web/CSS/:focus" title="/en-US/docs/Web/CSS/:focus">:focus</a>, and <a href="/en-US/docs/Web/CSS/:active" title="/en-US/docs/Web/CSS/:active">:active</a> CSS pseudo-classes</li>
</ul>
<p>For example, go to http://example.iana.org/:</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>Above this pane is a dedicated toolbar split into three sections:</p>
<p><img alt="" src="https://mdn.mozillademos.org/files/5427/inspector-html-toolbar-annotated.png" style="width: 910px; height: 443px; display: block; margin-left: auto; margin-right: auto;" /></p>
<ul>
  <li>Select element: if you click this button, you can then select a different element by mousing around in the browser window.</li>
  <li>HTML breadcrumbs: this shows the complete hierarchy through the document for the branch containing the selected element.</li>
</ul>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;mousing around in the browser window. Clicking it while no element is currently selected will select the element currently pointed at by the mouse.</p>
<dl>
  <dt>
    Breadcrumbs: element hierarchy (arrow keys)</dt>
  <dd>
    The majority of the toolbar is occupied by the breadcrumbs bar. This bar shows the hierarchy of all the nested elements, with its parent elements to the left and child elements to the right. Each element's element and CSS style and/or class is shown. If the information is cut off, mousing over the element's entry in the toolbar presents a tooltip with the complete description. If you click and hold on one of the elements in the bar, a popup menu appears that lets you select one of that element's siblings. Clicking the small arrow icons at the left and right ends of the bar will scroll the bar if it's wider than the available space; you can also use the arrow keys to navigate the element hierarchy bar.</dd>
  <dt>
    3D View button (Ctrl-W) {{ fx_minversion_inline("11.0") }}</dt>
  <dd>
    Toggles the <a href="/en/Tools/Page_Inspector/3D_view" title="en/Tools/Page_Inspector/3D_view">3D view</a> on and off. This button is only available if your system supports WebGL, but if available, clicking it lets you view the DOM hierarchy of your page as a 3D representation. If you don't see the 3D button, it is possible that your graphics driver needs to be updated. See the <a class="link-https" href="https://wiki.mozilla.org/Blocklisting/Blocked_Graphics_Drivers" title="https://wiki.mozilla.org/Blocklisting/Blocked_Graphics_Drivers">blocklisted drivers page</a> for more information.</dd>
  <dt>
    HTML button (Ctrl-H)</dt>
  <dd>
    The HTML button toggles on and off the <a href="/en/Tools/Page_Inspector/HTML_panel" title="en/Tools/Page_Inspector/HTML panel">HTML panel</a>, which provides a view at the HTML that created the selected element.</dd>
  <dt>
    Style button (Ctrl-S)</dt>
  <dd>
    The Style button toggles on and off the <a href="/en/Tools/Page_Inspector/Style_panel" title="en/Tools/Page_Inspector/Style panel">Style panel</a>, which shows the CSS responsible for styling the selected element.</dd>
</dl>
<h2 id="Keyboard_shortcuts">Keyboard shortcuts</h2>
<p>There are a number of handy shortcuts you can use while inspecting your page.</p>
<table class="standard-table" style="width: auto;">
  <tbody>
    <tr>
      <td class="header">Shortcut</td>
      <td class="header">Description</td>
    </tr>
    <tr>
      <td>←</td>
      <td>Moves to the parent of the selected node.</td>
    </tr>
    <tr>
      <td>→</td>
      <td>Moves to the first child of the selected node.</td>
    </tr>
    <tr>
      <td>↑</td>
      <td>Moves to the previous sibling of the selected node.</td>
    </tr>
    <tr>
      <td>↓</td>
      <td>Moves to the next sibling of the selected node.</td>
    </tr>
    <tr>
      <td>ESC</td>
      <td>Closes the Page Inspector.</td>
    </tr>
    <tr>
      <td>Return/Enter</td>
      <td>Locks and unlocks the currently highlighted element as the selected element to inspect.</td>
    </tr>
  </tbody>
</table>
<h2 id="Using_the_Page_Inspector_with_the_Web_Console">Using the Page Inspector with the Web Console</h2>
<p>You can, of course, use the Web Console at the same time as the Page Inspector. In fact, you even have a bonus feature! The element that's currently selected in the Page Inspector, if any, can be referenced in JavaScript in the Web Console using the variable <code>$0</code>.</p>
<p><img alt="web-console.png" class="internal default" src="/@api/deki/files/6078/=web-console.png" /></p>
<h2 id="See_also">See also</h2>
<ul>
  <li><a href="/en/Tools" title="Tools">Tools</a></li>
  <li><a href="/en/Tools/Web_Console" title="Using the Web Console">Using the Web Console</a></li>
  <li><a href="/en/Tools/Scratchpad" title="Scratchpad">Scratchpad</a></li>
</ul>
<p>{{ languages( { "ja": "ja/Tools/Page_Inspector"} ) }}</p>
Revert to this revision