For this workshop you will need:
- Chrome with Devtools
- This Devtools Workshop page
- Someone to keep track of the timer for each activity
You've already used a little bit of Devtools in ITD when you used Lighthouse to audit your code. But there's much much more! Devtools is an entire IDE (Integrated Development Environment) running inside your browser and it has hundreds of ways to inspect, test, and develop your code.
Each browser has its own Devtools. Download Safari, Chrome Canary, and Firefox Developer Edition to explore the differences.
Inspect the DOM
- [ ] Inspect the DOM
- [ ] Identify the values of design tokens in the CSS
- [ ] Alter the values of the CSS Variables using DevTools
In groups of no more than five. Take it in turns to swap the driver for each section of this workshop
-
Inspect the page with Devtools.
-
Write down the answers to these questions:
- What is the name of the font used on the page?
- What is the CSS variable that holds this value? (Hint: variables start with
--, like,--paper) - What is the brand colour value (Hint: it's set in a variable)?
- What is the brand colour value used for in the page?
- What variables hold CSS length data type values?
-
When the timer goes off, share your answers with the other groups. Paste them in a thread in Slack and go quickly to the next challenge.
So we've seen that fonts, colours, and spacing are often stored as CSS Variables, or custom properties. This allows them to be easily changed throughout a project by simply altering one value. Let's experiment with this.
-
Inspect the CSS of the page with Devtools.
-
Find the CSS Variables (hint: variables start with
--, for example,--paper) -
Try changing the values of these variables and see how it affects the page.
-
Some questions to answer. (Make a prediction about what you think will happen first, and then test it)
- What will happen when you click the value of
--fingerand pressup arrowten times? - What will happen when you delete the value of
--copy - What will happen when you change the value of
--spacetored?
- What will happen when you click the value of
When the timer goes off, set a new timer for 10 minutes to share your answers with the other groups.
- [ ] Select the Grid Badge in the Elements panel
- [ ] Use the Grid Editor to change layout
Next, let's see how the page layout is handled. Modern websites use the CSS Grid for layout and you can manipulate grids with Devtools.
- Set a whole class timer for 10 minutes.
- With Devtools, locate a grid element on the workshop page.
- Activate the Grid Badge in the Elements panel.
- Use the Grid Editor to try changing the layout.
- Go straight to the next challenge!
- [ ] Run a Lighthouse audit
- [ ] Identify and resolve the reported issues
It's important that software works and that people can use it. Lighthouse can help you write code correctly by pointing out your errors. But even better, it can teach you to fix the errors.
- Set a whole class timer for 10 minutes.
- Run a Lighthouse audit on the workshop page.
- Look at the results and identify the issue.
- Now, how will you fix it? Click on the error. Lighthouse explains what is wrong and provides a link to a detailed explanation on why it's wrong, how serious it is, and how to fix it!
- If you have time, fix the error, but in any case, once the timer goes off, paste the link to the detailed explanation page into the workshop thread in Slack.
- Go straight to the next challenge, after which we will spend some time discussing what we discovered.
- [ ] Find the MDN docs links in the Styles panel
In fact Devtools is a great teacher. In the Styles panel, hover over any CSS property to get a quick definition of that property. Click 'Learn More' to go straight to the MDN page for that property.
If the explanation doesn't make sense to you, have a discussion within your group and experiment changing it to figure out what it means.
Remember: Generative AIs are regularly confidently wrong; it can be helpful, but never trust it over official documentation.
If something doesn't make sense, or seems confusing or maybe wrong, it's better to ask friendly humans in Slack or in class.
- Set a timer for 10 minutes.
- Select
<main>in the Elements panel - Hover over the ruleset attached to main in the Styles panel.
- In your group, discuss what you think the rules mean. Refer to documentation or experiment if you need hints.
- Come back together as a large group.
- Set a timer for 5 minutes.
- Spend five minutes discussing what you will share with the rest of the class about your experiments so far. What was a surprise to you? What will you use regularly from now on? What confused you? Elect one person to represent your group.
- Set a timer for 20 minutes.
- Popcorn round the representatives and share your findings. We're not done yet so keep to time.
- [ ] Find a different API using the same code
- [ ] Inspect the Accessibility Tree and compare it to the DOM
So we've explored the Elements panel, the Styles panel, and the Lighthouse panel. There are many many more panels, and they all expose a different way of interpreting, interacting with, or understanding the same code. Computer systems frequently do this. It's a mistake to think that the way you use a website is the only way it can be used. Bots, crawlers, screen-readers, integrations... there are many and various consumers of your code, so it's important to make sure you construct it properly.
For example, you have just looked in the Elements panel. This is not really your HTML, this is the DOM, an API the browser builds using your HTML. An example of how the DOM is different from HTML is that JavaScript can change what's in the page - this changes the DOM, but doesn't change the actual HTML. The DOM isn't the only API it builds. Let's look at another one right now!
- Set a timer for 10 minutes.
- Discuss how your team will work on developing your skill with Devtools. Make your goals SMART. For example, you might audit a website you have built already with Lighthouse and improve its score using the guides. You might schedule a study group where each person researches and then teaches the group about a different panel in Devtools.
- Write down your learning goals with Devtools on a piece of paper and sign it underneath. Elect a new person to represent your group.
- Set a timer for 10 minutes.
- Popcorn round the representatives and share your commitments.
And that's it for today! We have covered a lot, but remember, as developers, we are lifelong learners. Always be curious and don't be afraid to explore new tools and concepts. Soon we'll dive even deeper into Devtools, so make sure to keep exploring.
-
Inspect web pages as you use the internet. Do this all the time! What font does YouTube use? What about CSS Tricks? Hackernews is still using tables - what's wrong with this?
-
Try changing the style and content of some websites. Make your favourite website bright pink. Try adding a
contenteditableattribute to an element and see what changes. Send a screenshot of something cool you changed to your cohort's Slack channel. -
There are crash courses in Devtools all over YouTube and Udemy. Find a useful tip and share it in your class channel.