HTML vs DOM? Let’s debug them #DevToolsTips

Chrome for Developers · Beginner ·🌐 Frontend Engineering ·2y ago

Key Takeaways

This video covers the basics of HTML and the Document Object Model (DOM), and how to debug them using Chrome DevTools, including inspecting and editing the DOM tree, and using console utilities API.

Full Transcript

[Music] what is the Dom and how does it relate to HTML in this episode we will explore two of the most common and confusing web development terms let's begin when you use a browser to request a web page the server returns HTML like this the HTML is a document with instructions on how the page should roughly look like the browser needs to process and pass the HTML to create a tree of objects like this each object of the tree is a note this entire tree representing the pages content is the Dom or we call it the document object model right now the Dom looks the same as the HTML but suppose that the script reference at the bottom runs this code it removes The Heading notes and adds another paragraph note to the Dom the complete Dom now looks like this the pages HTML is now different from its Dom in other words HTML represents initial page content and the Dom represents current page content when JavaScript adds removes or edits notes the Dom becomes different from the HTML in fact when building a page with a JavaScript framework you can use a very short HTML document and add all the notes from JavaScript that works the brows owser will pass it the same way to form the Dom with that let's inspect the page with death tools there are more than five ways to open death tools you can watch my previous video to learn more right click on the page and select inspect this is the elements panel on the left is the Dom tree this is where you can inspect edit and do all Dom related activities when you are interested in a particular Dom note inspect is a fast way to investigate that note with that the note is highlighted in the Dom tree furthermore as you navigate the notes Dev tools highlights the note in your page to there are three more handy commands to help you locate your note quicker you can use control or command F to search through the Dom if you find the Dom note is not currently in the viewport instead of scrolling all the way to the bottom you can click on the three Dot and select scroll into view in addition do you see the dollar hint in the D Tree you can press escape to bring out the console and type dollar Zer to view the current note you can also modify the text content on the Fly using this command to build the note in object format you can use the Dr command if you want to view your previous note in the navigation history type dollar one will get you that similarly you can right click and scroll to view from here this dollar command is part of the console utilities API go to this video to learn more useful commands like this since we touch on editing the Dom there are multiple easier ways to edit it as well this allows you to quickly experiment changes in the UI to edit the text content of a note double click on the text and start editing press enter to apply the changes similarly if you want to change the type of this node double click it enter the new type and press enter to add a new attribute like applying styles to the element you can right click select add attribute type in your attribute name and value look at that the color changed to deep Pink by the way you can use tab to navigate through the attributes for example double click on the note and press tab it will jump to the first attribute and you can edit the value on the fly if you want to add a hyperlink adding an anchor note like this doesn't work because Dev tools passes that as text right click on the note and select edit as HTML paste in your anchor and press enter easy peasy now here is a lesson known feature you can drag and drop the Dom node to move them around once you are done with your changes you can right click and take a no screenshot then send it to your designer take note though Dev tools won't save the changes you make in the Dom all changes are gone after you reload the page even if you have set up a workspace that makes sense because it's the Dom Dev to doesn't know where and how to save the changes should it be the HTML or JavaScript with workspace you should edit the actual file in the sources panel to save changes to your source code all right that's all for now to learn more about manipulating the Dom with de tools visit this link happy coding and stay tuned for the next St two tips [Music] ciao

Original Description

What is HTML? What is the DOM tree? Let's demystify them and learn how to debug them with DevTools. Chapters: 0:00 Intro 0:15 What is HTML 0:25 What is DOM 0:43 HTML vs DOM 1:11 Manipulate the DOM with JavaScript 1:33 Inspect the DOM 2:09 Locate DOM node quicker 2:27 Use $0 to console log a DOM node 3:03 Edit the DOM 4:09 Drag and drop the DOm node 4:15 Take a node screenshot 4:22 Persist changes with workspace Resources: https://goo.gle/devtools-dom https://goo.gle/devtools-workspace https://goo.gle/devtools-console-utils https://goo.gle/devtools-open Questions? Tweet to us: Jecelyn Yeen → https://goo.gle/jecfish Chrome DevTools → https://goo.gle/chromedevtools Catch more DevTools Tips → https://goo.gle/DevToolsTips Subscribe to Chrome for Developers → https://goo.gle/ChromeDevs #DevToolsTips
Watch on YouTube ↗ (saves to browser)
Sign in to unlock AI tutor explanation · ⚡30

Playlist

Uploads from Chrome for Developers · Chrome for Developers · 0 of 60

← Previous Next →
1 Polymer Performance Patterns (The Polymer Summit 2015)
Polymer Performance Patterns (The Polymer Summit 2015)
Chrome for Developers
2 Polymer Power Tools (The Polymer Summit 2015)
Polymer Power Tools (The Polymer Summit 2015)
Chrome for Developers
3 Chrome Dev Summit 2014 – Chrome Case Studies
Chrome Dev Summit 2014 – Chrome Case Studies
Chrome for Developers
4 Web Directions Code 2015 round up
Web Directions Code 2015 round up
Chrome for Developers
5 Maintainable Code - HTTP203
Maintainable Code - HTTP203
Chrome for Developers
6 iron-ajax… wat?! -- Polycasts #26
iron-ajax… wat?! -- Polycasts #26
Chrome for Developers
7 The Guardian - Supercharged
The Guardian - Supercharged
Chrome for Developers
8 ES2015 (next version of JavaScript), Totally Tooling Tips (S2 Ep1)
ES2015 (next version of JavaScript), Totally Tooling Tips (S2 Ep1)
Chrome for Developers
9 #AskPolymer: Rob answers all the questions ever -- Polycasts #27
#AskPolymer: Rob answers all the questions ever -- Polycasts #27
Chrome for Developers
10 The Future of JavaScript - HTTP203
The Future of JavaScript - HTTP203
Chrome for Developers
11 Data Binding 101 -- Polycasts #28
Data Binding 101 -- Polycasts #28
Chrome for Developers
12 The Guardian part 2 - Supercharged
The Guardian part 2 - Supercharged
Chrome for Developers
13 The Future of Web Audio: with Chris Wilson and Chris Lowis
The Future of Web Audio: with Chris Wilson and Chris Lowis
Chrome for Developers
14 Chrome 46: New motion-path animations, client hints and service worker improvements
Chrome 46: New motion-path animations, client hints and service worker improvements
Chrome for Developers
15 Sublime Snippets, Totally Tooling Tips (S2 Ep2)
Sublime Snippets, Totally Tooling Tips (S2 Ep2)
Chrome for Developers
16 #AskPolymer: How do you make the show? -- Polycasts #29
#AskPolymer: How do you make the show? -- Polycasts #29
Chrome for Developers
17 Critical Path CSS, Totally Tooling Tips (S2 Mini Tip #1)
Critical Path CSS, Totally Tooling Tips (S2 Mini Tip #1)
Chrome for Developers
18 Binding to Objects -- Polycasts #30
Binding to Objects -- Polycasts #30
Chrome for Developers
19 Player FM - Supercharged
Player FM - Supercharged
Chrome for Developers
20 Where’s the Designer? #AskPolymer -- Polycasts #31
Where’s the Designer? #AskPolymer -- Polycasts #31
Chrome for Developers
21 Jake Beats Wikipedia - HTTP203
Jake Beats Wikipedia - HTTP203
Chrome for Developers
22 Supercharged Observers! -- Polycasts #32
Supercharged Observers! -- Polycasts #32
Chrome for Developers
23 Jai's Web blog - Supercharged
Jai's Web blog - Supercharged
Chrome for Developers
24 Windows Command-line Tooling, Totally Tooling Tips (S2, Ep4)
Windows Command-line Tooling, Totally Tooling Tips (S2, Ep4)
Chrome for Developers
25 What about internationalization? #AskPolymer -- Polycasts #33
What about internationalization? #AskPolymer -- Polycasts #33
Chrome for Developers
26 Developing for Billions (Chrome Dev Summit 2015)
Developing for Billions (Chrome Dev Summit 2015)
Chrome for Developers
27 Google+ Performance Improvement Comparison
Google+ Performance Improvement Comparison
Chrome for Developers
28 Deploying HTTPS: The Green Lock and Beyond (Chrome Dev Summit 2015)
Deploying HTTPS: The Green Lock and Beyond (Chrome Dev Summit 2015)
Chrome for Developers
29 Progressive Web Apps (Chrome Dev Summit 2015)
Progressive Web Apps (Chrome Dev Summit 2015)
Chrome for Developers
30 Instant Loading with Service Workers (Chrome Dev Summit 2015)
Instant Loading with Service Workers (Chrome Dev Summit 2015)
Chrome for Developers
31 Increase Engagement with Web Push Notifications (Chrome Dev Summit 2015)
Increase Engagement with Web Push Notifications (Chrome Dev Summit 2015)
Chrome for Developers
32 Engaging with the Real World: Web Bluetooth and Physical Web (Chrome Dev Summit 2015)
Engaging with the Real World: Web Bluetooth and Physical Web (Chrome Dev Summit 2015)
Chrome for Developers
33 Asking for Permission: respectful, opinionated UI (Chrome Dev Summit 2015)
Asking for Permission: respectful, opinionated UI (Chrome Dev Summit 2015)
Chrome for Developers
34 Polymer - State of the Union (Chrome Dev Summit 2015)
Polymer - State of the Union (Chrome Dev Summit 2015)
Chrome for Developers
35 Building Progressive Web Apps with Polymer (Chrome Dev Summit 2015)
Building Progressive Web Apps with Polymer (Chrome Dev Summit 2015)
Chrome for Developers
36 Introduction to RAIL (Chrome Dev Summit 2015)
Introduction to RAIL (Chrome Dev Summit 2015)
Chrome for Developers
37 DevTools in 2015: Authoring to the max (Chrome Dev Summit 2015)
DevTools in 2015: Authoring to the max (Chrome Dev Summit 2015)
Chrome for Developers
38 RAIL in the real world (Chrome Dev Summit 2015)
RAIL in the real world (Chrome Dev Summit 2015)
Chrome for Developers
39 #ChromeDevSummit talks are up - W00T! -- Polycast #34
#ChromeDevSummit talks are up - W00T! -- Polycast #34
Chrome for Developers
40 V8 Performance from the Driver's Seat (Chrome Dev Summit 2015)
V8 Performance from the Driver's Seat (Chrome Dev Summit 2015)
Chrome for Developers
41 Quantify and improve real-world RAIL (Chrome Dev Summit 2015)
Quantify and improve real-world RAIL (Chrome Dev Summit 2015)
Chrome for Developers
42 Owning your performance: RAIL (Chrome Dev Summit 2015)
Owning your performance: RAIL (Chrome Dev Summit 2015)
Chrome for Developers
43 HTTP/2 101 (Chrome Dev Summit 2015)
HTTP/2 101 (Chrome Dev Summit 2015)
Chrome for Developers
44 Leadership Panel (Chrome Dev Summit 2015)
Leadership Panel (Chrome Dev Summit 2015)
Chrome for Developers
45 Build Processes, Totally Tooling Tips (S2, Ep 5)
Build Processes, Totally Tooling Tips (S2, Ep 5)
Chrome for Developers
46 Accessibility (Chrome Dev Summit 2015)
Accessibility (Chrome Dev Summit 2015)
Chrome for Developers
47 Binding to Arrays -- Polycasts #35
Binding to Arrays -- Polycasts #35
Chrome for Developers
48 HTTP2 - HTTP203
HTTP2 - HTTP203
Chrome for Developers
49 Chrome 47: Splash Screens, requestIdleCallback and better desktop notifications (New in Chrome)
Chrome 47: Splash Screens, requestIdleCallback and better desktop notifications (New in Chrome)
Chrome for Developers
50 Call For Submissions - Supercharged
Call For Submissions - Supercharged
Chrome for Developers
51 Cross Device Testing, Totally Tooling Tips (S2 Ep6)
Cross Device Testing, Totally Tooling Tips (S2 Ep6)
Chrome for Developers
52 Testing AJAX with Web Component Tester -- Polycasts #37
Testing AJAX with Web Component Tester -- Polycasts #37
Chrome for Developers
53 Slack: Extended Xmas Special - Supercharged
Slack: Extended Xmas Special - Supercharged
Chrome for Developers
54 Browser testing with Travis & Sauce Labs -- Polycasts #38
Browser testing with Travis & Sauce Labs -- Polycasts #38
Chrome for Developers
55 Optimize for production with Vulcanize -- Polycasts #39
Optimize for production with Vulcanize -- Polycasts #39
Chrome for Developers
56 Highlights from Chrome Dev Summit 2015
Highlights from Chrome Dev Summit 2015
Chrome for Developers
57 Chrome 48: Custom buttons in notifications, DevTools Security panel, and Presentation mode
Chrome 48: Custom buttons in notifications, DevTools Security panel, and Presentation mode
Chrome for Developers
58 Crisper: Protecting your Polymer app with CSP -- Polycasts #40
Crisper: Protecting your Polymer app with CSP -- Polycasts #40
Chrome for Developers
59 How do I use Sass with Polymer? #AskPolymer -- Polycasts #41
How do I use Sass with Polymer? #AskPolymer -- Polycasts #41
Chrome for Developers
60 Colors – DevTools Tonight #0 (Pilot)
Colors – DevTools Tonight #0 (Pilot)
Chrome for Developers

This video teaches the basics of HTML and the DOM, and how to use Chrome DevTools to debug and manipulate the DOM tree. It covers inspecting and editing the DOM, using console utilities API, and provides tips for efficient debugging.

Key Takeaways
  1. Open DevTools and inspect the DOM tree
  2. Use control/command F to search through the DOM
  3. Click on the three dots and select scroll into view
  4. Use $0 to console log a DOM node
  5. Edit the text content of a node by double clicking on the text
  6. Add a new attribute by right clicking and selecting add attribute
💡 The DOM represents the current state of the page, while HTML represents the initial page content. Changes made to the DOM using DevTools are not saved and are lost after reloading the page.

Related Reads

📰
Inside the Wayfair Frontend SDE-2 Interview: A Complete Breakdown
Learn how to prepare for a Frontend SDE-2 interview at Wayfair, including online assessments, machine coding, and system design.
Medium · Programming
📰
I Spent Two Years Maintaining a React SPA. HTMX Rebuilt It in a Week
Learn how HTMX rebuilt a React SPA in a week, replacing 2 years of maintenance work, and discover the benefits of this alternative approach
Medium · Programming
📰
The 5 Levels of Front End Engineering (And Where Most Developers Get Stuck)
Learn the 5 levels of front end engineering to improve your skills and avoid getting stuck in a career rut
Medium · Programming
📰
Browser-Based PDF Editing with Vue 3 and pdf-lib
Learn to build a browser-based PDF editor using Vue 3 and pdf-lib, enabling users to edit PDFs directly in the browser
Dev.to · sunshey

Chapters (12)

Intro
0:15 What is HTML
0:25 What is DOM
0:43 HTML vs DOM
1:11 Manipulate the DOM with JavaScript
1:33 Inspect the DOM
2:09 Locate DOM node quicker
2:27 Use $0 to console log a DOM node
3:03 Edit the DOM
4:09 Drag and drop the DOm node
4:15 Take a node screenshot
4:22 Persist changes with workspace
Up next
How To Build A Twitter Clone - React Next JS - Appwrite Crash Course
Adrian Twarog
Watch →