Class 10 - Browser Developer Tools

CSS Foundations

Browser Developer Tools 🔍

CSCI 3403 - Web Programming

Week 5, Class 10

Your most powerful debugging weapon! 🛠️

Why Browser DevTools? 🤔

The Web Developer's Swiss Army Knife

Industry Reality: You'll spend 50% of your time in DevTools!

Today's Learning Objectives

Hands-On Class: Have Chrome open and ready!

Three Ways to Open DevTools 🚪

1. Right-Click Method

Right-click any element → "Inspect"

Opens DevTools focused on that element!

2. Keyboard Shortcut

F12

or

Ctrl+Shift+I (Win/Linux)

Cmd+Option+I (Mac)

3. Chrome Menu

⋮ Menu → More Tools → Developer Tools

The slowest way, but it's there!

DevTools Layout Overview 🗺️

Elements Panel 📄

  • HTML DOM tree
  • Live element structure
  • Add/edit/delete elements

Styles Panel 🎨

  • All CSS rules for selected element
  • Computed styles
  • Box model visualization

Console 💻

  • JavaScript errors/logs
  • Run JS commands
  • Debug output

Network 🌐

  • Loading times
  • Failed resources
  • Request/response data
Today's Focus: Elements and Styles panels - your CSS debugging headquarters!

Demo 1: Basic Element Inspection 🔍

Let's Inspect This Page!

I'm a demo element!

Right-click me and select "Inspect"

And Me!
Me Too!

Follow Along:

  1. Right-click any element above
  2. Click "Inspect"
  3. Notice how DevTools highlights the element
  4. Look at the HTML in Elements panel

The Element Selector Tool 🎯

🔍 Click the selector icon (or press Ctrl+Shift+C)

How it works:

  1. Click the selector icon in DevTools (top-left corner)
  2. Hover over any element on the page
  3. See live highlighting with dimensions
  4. Click to select and inspect that element
Pro Tip: The selector shows margin (orange) and padding (green) visually!

Try it now:

Use the selector tool to inspect 3 different elements on this page

The DOM Tree 🌳

<body> <div class="container"> <header> <h1>My Website</h1> <nav>...</nav> </header> <main> <section>...</section> </main> </div> </body>

Navigation Tips:

Remember: Changes in DevTools are temporary - refresh and they're gone!

Understanding the Styles Panel 🎨

element.style { }

.my-class {
  color: blue;
  color: red;
}

inherited from body {
  font-family: Arial;
}

What you'll see:

Demo 2: Live Style Editing ✏️

Change My Styles!

Use DevTools to modify me

Let's modify together:

  1. Inspect the blue box above
  2. In Styles panel, click on the background color
  3. Change it to #ff6b6b
  4. Add a new property: transform: rotate(5deg)
  5. Disable/enable properties with checkboxes
Keyboard Shortcuts in Styles: ↑↓ change values | Tab next property | Esc cancel

Adding New CSS Rules

Three ways to add styles:

1. element.style

Click in the empty element.style {} block

Adds inline styles to that specific element

2. Existing Selector

Click inside any existing CSS rule

Add new properties to that rule

3. New Rule Button (+)

Click the + button in Styles panel

Creates a new CSS rule with auto-generated selector

Remember: Great for testing, but copy working CSS to your actual files!

Built-in Developer Tools 🛠️

Click on any color value to open:

Other helpful tools:

Demo 3: Real-World Debugging 🐛

Why am I red? 🤔

My text is too small!

Debug Challenge:

Use DevTools to find out:

  1. Why is the heading red instead of #333?
  2. What's making the paragraph text small?
  3. Why isn't the button purple (#667eea)?

Box Model in DevTools 📦

In the Styles panel, scroll down to find:

Content
Padding
Border
Margin
Pro Tip: Hover over the box model to highlight that area on the page!

The Computed Tab 🧮

Shows the FINAL computed values

Styles Tab

  • Shows all CSS rules
  • Shows overrides
  • Shows source files
  • Can have conflicts

Computed Tab

  • Shows final values only
  • Alphabetically sorted
  • Shows inherited values
  • Shows winning rule
When to use Computed: When you need to know the ACTUAL value being applied, not the rules fighting for control!

Quick Console Magic 🎩

Selecting elements with JavaScript:

// Select by ID document.querySelector('#myId') // Select by class document.querySelector('.myClass') // Select all matching elements document.querySelectorAll('p') // Quick shortcuts in console $0 // Currently selected element $('selector') // Short for document.querySelector $$('selector') // Short for document.querySelectorAll

Try in Console:

  1. Open Console tab
  2. Type: document.querySelector('h1')
  3. Type: $0.style.color = 'red'
  4. See the magic happen!

Practice Activity 1: Element Hunt 🔍

10-Minute Challenge

Visit any popular website (CNN, Amazon, etc.) and:

  1. Use the selector tool to find:
    • The main navigation menu
    • The largest image on the page
    • A button or link
  2. For each element, identify:
    • Its HTML tag
    • Its main CSS class
    • Its font-size and color
  3. Change at least 3 CSS properties
  4. Take a screenshot of your changes!

Practice Activity 2: CSS Detective 🕵️

Partner Activity (5 minutes each)

In pairs, take turns:

  1. Partner A: Opens their one-page website
  2. Partner B: Uses DevTools to:
    • Find an element with conflicting CSS (strikethrough)
    • Identify which rule is "winning"
    • Add a new CSS property
    • Change an existing color or size
  3. Switch roles after 5 minutes
  4. Share one interesting finding with the class

Essential Keyboard Shortcuts ⌨️

Opening DevTools

F12 Open DevTools

Ctrl+Shift+C Inspect element

Ctrl+Shift+J Open Console

While in DevTools

Ctrl+F Search in panel

Esc Toggle console drawer

Ctrl+] Next panel

In Styles Panel

↑↓ Increment values

Shift+↑↓ ±10

Alt+↑↓ ±0.1

Mac Equivalents

Replace Ctrl with Cmd

Replace Alt with Option

Bonus: Responsive Design Mode 📱

Click the device icon 📱 or press Ctrl+Shift+M

Test your site on different devices:

Coming Soon: We'll dive deep into responsive design in a few weeks!

Homework Assignment 📚

Due: Before Next Class

Complete The Odin Project Readings:

  1. 📖 Chrome DevTools Overview
  2. 📖 Open Chrome DevTools
  3. 📖 Get Started With Viewing And Changing The DOM
  4. 📖 View and Change CSS (with interactive exercises!)

Practice Exercise:

Using DevTools on your one-page website:

  1. Find and fix any CSS conflicts (strikethrough styles)
  2. Experiment with 5 new CSS properties
  3. Use the color picker to create a new color scheme
  4. Take screenshots of before/after

Pro Developer Tips 💡

Remember: DevTools changes are temporary! Always copy successful changes to your actual CSS files!

Today's Key Takeaways 🎯

You Can Now:

Next Class: The Cascade - How CSS rules fight and win!

Questions & Open Practice 🤔

Common Questions:

Remaining Time:

Practice with DevTools on your own site or explore other websites!

I'll walk around to help with questions.

You're Now a DevTools Ninja! 🥷

Remember:

DevTools is your best friend in web development!

The more you use it, the faster you'll debug.

Challenge for this week:

Use DevTools to inspect every website you visit!

Try to understand how they built their layouts.

See you next class for CSS Cascade! 🌊