Most modern browsers have built-in developer tools that allow you to view, analyze, and edit the DOM, get information about HTTP requests and responses and other browser activity, and run javascript on a console. In this exercise, we will use Google Chrome's developer tools on the Sample Website from Exercise 0.2. Open this website in another tab by using CTRL-Click (Windows) or COMMAND-Click (Mac).
Please practice using each of these three ways to open Chrome developer tools:
• CTRL-SHIFT-I (Windows) or COMMAND-SHIFT-I (Mac) to toggle the tools open and closed.
• Go to an Element, RIGHT-CLICK (Windows) or ALT-CLICK (Mac), then click "Inspect."
• Open the Chrome menu (three dots), click "More Tools," then click "Developer Tools."
The Elements tab lets you view, analyze, and edit the DOM.
• Open the Sample Website.
• Open Developer Tools > Elements tab.
• Practice using the expand/collapse arrows.
• Change the text inside an element.
• Change the href of an <a> link.
• Right-click (alt-click) on <nav>, and
click "Edit as HTML." Write a new nav.
• Select an <a> and click "Styles."
• Add "style:padding:10px" to the element.
See how the "styles" area changes.
• Click "Computed".
• Change the "style" and see what changes.
• Refresh page with developer tools still open.
The Console tab lets you run javascript. It also shows errors.
• Open the Sample Website.
• Open Developer Tools > Console tab.
• Run the following code snippets:
(Hover or click for explanation)
The Network tab gives you information about requests and responses.
• Open the Sample Website.
• Click on Contact link.
• Open Developer Tools > Network tab.
• Refresh with developer tools still open.
• Click the first line (contact.html), then:
- "Headers" (shows HTTP headers)
- "Response"(shows HTML).
- "Preview" (rendered without img)
• Click the second line (batsignal.jpg), then:
- "Headers" (shows HTTP headers)
- "Response"(shows image encoding).
- "Preview" (rendered image)