in

Unveiling Lesser-Known Cross-Browser DevTools Features | CSS-Tricks: A Skilled SEO & Expert Copywriter’s Take



**Search Nodes in the DOM Tree: Finding Elements Easily**
Searching for specific elements in the DOM tree can be a challenging task, especially when dealing with nested nodes. However, DevTools provides a useful feature that allows you to search the DOM tree quickly. By using the shortcut Cmd + F (macOS) or Ctrl + F (Windows), you can initiate a search and find the exact node you’re looking for. In addition to searching by text, you can also use CSS selectors or XPath to locate elements. This feature is available in Chromium-based browsers like Chrome, Edge, and Opera.

**Customize the Search Behavior in Chromium Browsers**
In Chromium browsers, the search functionality in DevTools has a built-in behavior that automatically jumps to the matching node as you type. While this can be helpful in some cases, it can become frustrating when dealing with longer search queries or large DOM trees. Fortunately, you have the option to disable this behavior. To do so, navigate to Settings (F1) → Preferences → Global → Search as you type → Disable. By disabling this feature, you can have more control over your search process.

**Accessing DOM Nodes from the Console**
DevTools offers various ways to access DOM nodes directly from the console. One commonly used method is the use of a shortcut. For example, in Chromium browsers, you can use $0 to access the currently selected node in the DOM tree. Furthermore, you can use $1, $2, $3, etc., to access nodes selected in reverse chronological order. Additionally, Chromium browsers allow you to copy the node path as a JavaScript expression. By right-clicking on a node and selecting “Copy → Copy JS path,” you can obtain a JavaScript expression (document.querySelector) that can be used to access the node in the console.

Another method to access DOM nodes directly from the console is by using a temporary variable. This option is available by right-clicking on the node and selecting the corresponding option. In Chromium browsers, it is labeled as “Store as global variable,” while Firefox labels it as “Use in Console,” and Safari refers to it as “Log Element.”

**Visualizing Elements with Badges**
DevTools has a feature that allows you to visualize elements with badges. Badges are small icons displayed next to specific nodes, indicating certain properties. For example, in Safari, a badge button in the Elements panel toolbar lets you toggle the visibility of specific badges. If a node has a CSS declaration like display: grid or display: inline-grid, a grid badge will be displayed next to it. Clicking on the badge will reveal additional information about grid areas, track sizes, and line numbers.

Similarly, Firefox’s DevTools support a range of badges that can be found in the Firefox source docs. One example is the scroll badge, which indicates a scrollable element. Clicking on the badge highlights the element causing the overflow.

In Chromium browsers, you can access the badge settings by right-clicking on any node and selecting “Badge settings…”. This will open a container that lists all available badges. For example, nodes with scroll-snap-type applied to them will display a scroll-snap badge. Clicking on this badge will toggle the scroll-snap overlay on the element.

**Taking Screenshots with DevTools**
Taking screenshots directly from DevTools has been a feature for some time and is now available in all major browsers. Each browser has its own method for capturing screenshots, including new options for taking full-page shots.

To capture a screenshot of a specific DOM node, right-click on the node and select the corresponding option. The labeling of this option may vary between browsers. For example, in Chrome, it is labeled as “Capture node,” while Safari uses “Capture Screenshot” and Firefox uses “Capture Node Screenshot.”

To capture a full-page screenshot, repeat the same steps on the html node. Keep in mind that there is a slight difference in how Safari handles the background color of captured elements. While Safari retains the transparency of the element’s background color, Chromium and Firefox capture it with a white background.

Additionally, you can take “responsive” screenshots of the page, allowing you to capture the page at a specific viewport width. The method to launch responsive design mode varies between browsers. In Chromium, use the shortcut Cmd + Shift + M (macOS) or Ctrl + Shift + M (Windows), or click the “Devices” icon next to the “Inspect” icon. In Firefox, navigate to Tools → Browser Tools → “Responsive Design Mode,” and in Safari, go to Develop → “Enter Responsive Design Mode.”

**Inspecting Top-Layer Elements in Chrome**
Chrome’s DevTools provide a feature for visualizing and inspecting top-layer elements such as dialogs, alerts, or modals. When an element is added to the #top-layer, it is marked with a top-layer badge. Clicking on this badge will jump you to the top-layer container just after the </html> tag. The order of elements in the top-layer container follows the stacking order, with the last element being on top. You can click the reveal badge to return to the node you were previously inspecting.

**Jump to ID in Firefox**
Firefox offers a convenient feature that allows you to jump to elements referenced by their ID attribute. When you hover over an element referencing an ID, Firefox highlights the target element in the same DOM structure and underlines it. To navigate directly to the target element, use the shortcut CMD + Click (macOS) or CTRL + Click (Windows).

**Staying Informed: Resources for Chrome, Firefox, and Safari DevTools**
It’s important to stay up to date with the latest features and capabilities of DevTools. Fortunately, there are resources available that can help you stay informed. Here are a few that I find useful:

1. The official documentation for each browser’s DevTools: Chrome DevTools documentation, Firefox DevTools documentation, and Safari Web Inspector documentation.
2. Developer blogs and websites that regularly cover DevTools updates and tips. Some popular ones include the DevTools section of the Chrome Developers website, the Mozilla Hacks Developer Tools category, and the WebKit blog.

In conclusion, DevTools offer a wide range of powerful features across Chromium, Firefox, and Safari. By utilizing these lesser-known features, you can enhance your debugging and development workflow. Keep exploring and experimenting with DevTools to discover even more hidden gems that can save you time and effort in your web development projects.



Leave a Reply

Your email address will not be published. Required fields are marked *

GIPHY App Key not set. Please check settings

Unveiling the Enigma: A Puzzling Interstellar Radio Signal Keeps Flashing at Precise Intervals of 22 Minutes, Continuing its Beams for Over Three Decades

Exploring Real-World Object Navigation: A Machine Learning Blog by ML@CMU