Dev Tips: DevTools:️ How deactivated CSS styles works

Dev Tips

 

DevTools: How copying and pasting deactivated CSS styles works

DevTools has some small, yet handy features when it comes to dealing with styles.

If you copy some deactivated style rules, they are commented out when you paste them in, for example, in your code editor.

An example

Say you have the following in your DevTools styles pane:

.container {
    ☑ width: 100%;
    ☑ margin-left: auto;
    ☐ margin-right: auto;
    ☑ max-width: 1280px;
}

Copying the code above (from within DevTools) and then pasting it into your editor presents this:

.container {
    width: 100%;
    margin-left: auto;
    /* margin-right: auto; */
    max-width: 1280px;
}

The Sources Panel

This feature is also compatible with the Sources Panel, meaning if you comment out a CSS style in the Elements Panel, the raw source code as shown in the Sources Panel will reflect those changes.

A screenshot showing how DevTools comments out the CSS of a deactivated style

Note: In my testing, I did observe some bugs when dealing with Source Maps (e.g. Sass code).

This feature works the other way also. If you comment out a CSS style in the Sources Panel, the Style Pane in the Elements Panel reflects your changes and deactivates the corresponding styles.

A screenshot showing how DevTools reflects your changes from the Sources Panel, back to the Styles Pane in the Elements Panel

Bonus Tip

As a bonus tip, you can Command + Click (or Control + Click) on a CSS style from the Styles Pane in the Elements Panel. When you do this, you are taken straight to the Sources Panel code with the revelvant line of code highlighted.

Here's the web version of this email: umaar.com/dev-tips/232-copy-paste-deactivated-styles

Email Marketing Powered by Mailchimp

Copyright © 2020 Umar, All rights reserved.
You are receiving this email because you signed up for Dev Tips.

unsubscribe from this list    update subscription preferences 

Older messages

DevTools: Improve accessibility by emulating vision deficiencies

Friday, July 10, 2020

Dev Tips Chrome DevTools: Improve page accessibility by emulating vision deficiencies Web developer tooling to improve accessibility has improved rapidly over the years. Emulating vision deficiencies

Dev Tips: JavaScript: ⚡️ Improve the performance of your event listeners

Wednesday, July 1, 2020

Dev Tips I've been blogging more on my website, go and check it out! JavaScript: Improve the performance of your event listeners In your JavaScript code, you can automatically remove an event

Dev Tips: DevTools: Copy an element into your clipboard with this keyboard only workflow

Saturday, June 20, 2020

Dev Tips Thank you for voting for the next video course. Will update you next month! DevTools: Copy an element into your clipboard with this keyboard only workflow You can get any element into your

You Might Also Like

💻 Issue 437 - Introducing local Azure Service Bus Emulator

Thursday, November 21, 2024

This week's Awesome .NET Weekly Read this email on the Web The Awesome .NET Weekly Issue » 437 Release Date Nov 21, 2024 Your weekly report of the most popular .NET news, articles and projects

💎 Issue 444 - Why did people rub snow on frozen feet? (2017)

Thursday, November 21, 2024

This week's Awesome Ruby Newsletter Read this email on the Web The Awesome Ruby Newsletter Issue » 444 Release Date Nov 21, 2024 Your weekly report of the most popular Ruby news, articles and

💻 Issue 444 - JavaScript Dos and Donts

Thursday, November 21, 2024

This week's Awesome JavaScript Weekly Read this email on the Web The Awesome JavaScript Weekly Issue » 444 Release Date Nov 21, 2024 Your weekly report of the most popular JavaScript news, articles

📱 Issue 438 - Reverse Engineering iOS 18 Inactivity Reboot

Thursday, November 21, 2024

This week's Awesome iOS Weekly Read this email on the Web The Awesome iOS Weekly Issue » 438 Release Date Nov 21, 2024 Your weekly report of the most popular iOS news, articles and projects Popular

💻 Issue 362 - React Anti-Pattern: Stop Passing Setters Down the Components Tree

Thursday, November 21, 2024

This week's Awesome React Weekly Read this email on the Web The Awesome React Weekly Issue » 362 Release Date Nov 21, 2024 Your weekly report of the most popular React news, articles and projects

💻 Issue 444 - Building simple event-driven applications with Pub/Sub

Thursday, November 21, 2024

This week's Awesome Node.js Weekly Read this email on the Web The Awesome Node.js Weekly Issue » 444 Release Date Nov 21, 2024 Your weekly report of the most popular Node.js news, articles and

📱 Issue 441 - Shift Left Is the Tip of the Iceberg

Thursday, November 21, 2024

This week's Awesome Swift Weekly Read this email on the Web The Awesome Swift Weekly Issue » 441 Release Date Nov 21, 2024 Your weekly report of the most popular Swift news, articles and projects

💻 Issue 439 - Async/Await Is Real And Can Hurt You

Thursday, November 21, 2024

This week's Awesome Rust Weekly Read this email on the Web The Awesome Rust Weekly Issue » 439 Release Date Nov 21, 2024 Your weekly report of the most popular Rust news, articles and projects

📲 Why I Ditched Linux for Samsung DeX — Buy This Instead of a Gaming Headset

Thursday, November 21, 2024

Also: Taking Instagram Stories to the Next Level, and More! How-To Geek Logo November 21, 2024 Did You Know Thurl Ravenscroft was both the voice behind the Christmas song "You're a Mean One,

Ranked | The World's 30 Largest Exporters 🌎

Thursday, November 21, 2024

We show the largest exporters in the world amid a surge in trade restrictions, rising populism, and shipping route disruptions. View Online | Subscribe | Download Our App 5 DAYS LEFT! Learn Visual