D276 Chapter 7 — Debugging Processes and Testing Tools
0.0(0)
Studied by 0 people
Call Kai
Learn
Practice Test
Spaced Repetition
Match
Flashcards
Knowt Play
Card Sorting
1/45
Earn XP
Description and Tags
46 cards for WGU D276 zyBooks Chapter 7 (Debugging Processes and Testing Tools) and its assigned MDN readings (Debugging HTML, Debugging CSS): key terms plus concept, vs and debugging-scenario cards. Each back cites (7.1).
46 Terms
1
New cards
debugging
The practice of finding and resolving coding errors: mistakes in HTML code that may result in webpage errors or other strange website behaviors. Even the best HTML programmers make mistakes; making corrections is a normal step in the HTML coding process. (7.1)
2
New cards
self-correcting (HTML errors)
HTML errors that the web browser will automatically fix. | Other HTML errors cannot be corrected by the browser; these may prevent the webpage from rendering, or it might display incorrectly. (7.1)
3
New cards
compiled vs. interpreted (HTML)
HTML is not compiled into a different form before parsing: it is interpreted, not compiled. (MDN Debugging HTML contrasts it with a Rust program that has to be compiled.) (7.1)
4
New cards
permissive (parsing)
Browsers parse HTML a lot more permissively than most programming languages are parsed, meaning the page still displays even if there are syntax errors in the source code. | Both good and bad: you always get something, but the browser doesn't always get it right. (7.1)
5
New cards
syntax errors
Typos in your code that cause the program not to run. Usually easy to fix as long as you are familiar with the language's syntax and know what the error messages mean. (7.1)
6
New cards
logic errors
Errors where the syntax is actually correct, but the code is not doing what you intended, so the program runs incorrectly. Often harder to fix than syntax errors, as there isn't an error message to direct you to the source of the error. (7.1)
7
New cards
invalid / badly-formed markup
Incorrectly-written HTML markup. Browsers have built-in rules that state how to interpret it, changing it automatically to some valid markup. (7.1)
8
New cards
developer tools (devtools / DevTools)
A set of tools built into all modern browsers for examining the webpage loaded in the current tab: what HTML is rendered, what CSS is applied to each DOM node, what JavaScript is running, and more. You can edit the currently-running code and see the effect live. | Per MDN Debugging CSS, they help you find out what is going on with a CSS problem; know how to open them in other browsers too, which helps if rendering differs between browsers. (7.1)
9
New cards
DOM inspector
The devtools function that shows the currently-rendered HTML DOM and allows you to edit it. It is the first tab in the devtools: labeled Inspector in Firefox and Elements in Safari, Edge, and Chrome. (7.1)
10
New cards
Markup Validation Service / HTML validator
A tool created and maintained by the W3C (https://validator.w3.org/) that takes an HTML document as input, goes through it, and gives you a report telling you what is wrong with your HTML. | Provide a web address, upload an HTML file, or paste code on the Validate by Direct Input tab, then press Check. Each message has a line and column number. (7.1)
11
New cards
View Source
The HTML source code as stored on the server: what you see when you view the source of a webpage. Contrast it with the rendered DOM shown in DevTools. (7.1)
12
New cards
rendered DOM / HTML tree (HTML Pane)
The HTML tree in DevTools shows exactly what the browser is rendering at any given time. The browser may have normalized the HTML (e.g., an <h2> wrongly closed with </h3> is shown closed with </h2>), and the DOM also shows any changes made by JavaScript. (7.1)
13
New cards
Inspect (DevTools)
Right/ctrl-click an element on the page and select Inspect to select it in DevTools (or select it from the HTML tree). Its applied CSS then shows in the Rules view. (7.1)
14
New cards
Rules view
The DevTools panel to the right of the HTML that shows the CSS properties and values applied to the selected element: rules applied directly to it and CSS it inherits from its ancestors. | Hover over a declaration for a checkbox to toggle it off and on; overridden declarations and declarations with invalid values are crossed out. (7.1)
15
New cards
shorthand / longhand properties
A shorthand property such as margin can be expanded in the Rules view (click the little arrow) to show the different longhand properties and their values. (7.1)
16
New cards
A/B comparison
Toggling a declaration off and on in the Rules view (uncheck its checkbox, e.g., border-radius) to decide if something looks better with the rule applied or not, or to work out which property is causing a layout problem. (7.1)
17
New cards
swatch / color picker
The swatch is the small colored circle that shows a color applied (e.g., to a border). Clicking it opens a color picker; colors you try update in real time on the page. (7.1)
18
New cards
adding a new property (DevTools)
Click the closing curly brace in a rule to start entering a new declaration; DevTools shows an autocomplete list of matching properties (e.g., font-size), then you enter a value. Or click the + button to add an additional rule with the same selector. | Try it in DevTools before adding it to your CSS file. (7.1)
19
New cards
Layout view
DevTools view that shows a diagram of the box model on the selected element, plus a description of the properties and values that change how it is laid out, including properties not explicitly set that have initial values. (7.1)
20
New cards
box-sizing (property)
The CSS property that controls what box model an element uses: content-box or border-box. The DevTools Layout view lists it. (7.1)
21
New cards
content-box
The box-sizing value that takes the size you give the element and then adds on the padding and border width. | Ex: MDN's box1 has width: 400px but is visually wider than 400px. (7.1)
22
New cards
border-box
The box-sizing value where the padding and border are subtracted from the size you give the element, so the space the box takes up on the page is the exact size you specified. | Ex: MDN's box2 takes up exactly width: 400px. (7.1)
23
New cards
specificity (override in DevTools)
When some CSS just won't apply, a more specific selector is generally overriding your changes. Class selectors are more specific than element selectors. DevTools shows what applies and crosses out the overridden property. (7.1)
24
New cards
CSS Validator (W3C)
W3C tool (https://jigsaw.w3.org/css-validator/) used to check for badly-formed CSS code. Running your HTML and CSS through validators is a good first step when debugging. (7.1)
25
New cards
unsupported CSS
Browsers ignore CSS they don't understand. If a property or value isn't supported by the browser you're testing in, nothing breaks, but that CSS isn't applied. DevTools generally highlights unsupported properties and values. (7.1)
26
New cards
Browser compatibility tables
Tables at the bottom of each property page on MDN that show browser support for that property, often broken down if some usages are supported and others aren't. (7.1)
27
New cards
reduced test case
A code example that demonstrates the problem in the simplest possible way, with unrelated surrounding content and styling removed. Used to find problems in your own and colleagues' code, ask for help, and file browser bug reports. (7.1)
28
New cards
CodePen
A code sharing site (https://codepen.io/) useful for hosting reduced test cases, so they are accessible online and easy to share with colleagues. (7.1)
29
New cards
Syntax error vs logic error
Syntax error = a typo that stops the program from running; an error message points to it, so it's usually easy to fix. | Logic error = correct syntax, but the code does the wrong thing; there's no error message, so it's usually harder to fix. (7.1)
30
New cards
Why does HTML not "suffer from" syntax errors, and why is that a mixed blessing?
Browsers parse HTML permissively: the page still displays despite syntax errors, because built-in rules turn invalid markup into valid markup. | Good: you always get something running. Bad: the browser doesn't always get it right, so write correct markup in the first place. | Why: when the web was created, getting content published mattered more than perfect syntax. (7.1)
31
New cards
View Source vs the DOM in DevTools
View Source = the HTML source code as stored on the server. | DevTools HTML tree = the rendered DOM: exactly what the browser is rendering now. It may be normalized (bad HTML corrected) and shows changes made by JavaScript. (7.1)
32
New cards
Where is the DOM inspector, and how do you move around in it?
The first tab in the devtools (selected by default): Inspector in Firefox, Elements in Safari, Edge, and Chrome. | Click the little arrows to expand/collapse nodes. Up/down cursor keys move between nodes; right/left expand and collapse them. Hovering over (or selecting) a node highlights its element in the viewport. (7.1)
33
New cards
Code reading: <p>I didn't expect to find the <em>next-door neighbor's <strong>cat</em></strong> here!</p>. What's wrong, and what does the rendered DOM show?
Bad nesting: the closing </strong> tag should come before the closing </em> tag. | The browser corrects it in the DOM: <em>next-door neighbor's <strong>cat</strong></em>. Here it got the intended result, but it doesn't always. (7.1)
34
New cards
Scenario: a <strong> element is never closed. What happens on the page and in the DOM?
The whole rest of the text renders bold, since it isn't clear where the element should end. | In the DOM, the browser wraps each separate block of text in its own <strong> element, right down to the bottom of the document. The validator reports "Unclosed element strong" at its line and column. (7.1)
35
New cards
Scenario: a link doesn't appear at all. The source has <a href="https://www.mozilla.org/>link to Mozilla homepage</a>. Why?
The href value is missing its closing double quote, so the rest of the document is read as the attribute's content. The browser deleted the link altogether. | Fix: href="https://www.mozilla.org/". Validator clues: "End of file reached when inside an attribute value. Ignoring tag" and a misleading "Unclosed element ul". (7.1)
36
New cards
Validator message: End tag li implied, but there were open elements. What does it mean?
An element is open that should be closed: the ending tag is implied but not actually there. The line/column information points to the first line after where the closing tag should really be. (7.1)
37
New cards
The validator says Unclosed element ul, but the </ul> is there. Why?
The message is misleading: the <a> element before it was never closed, because its href was missing a closing quote mark. Fixing the quote clears it. (7.1)
38
New cards
Strategy for a long list of HTML validator errors?
Don't worry if you can't decode every message. Fix a few errors at a time, then revalidate to see what's left. Several errors are often caused by a single problem (a domino effect), so an early fix can clear others. | Done when a green banner says "Document checking completed. No errors or warnings to show." (7.1)
39
New cards
Scenario: an element shows a font size you never set on it. Where do you look, and what do you do?
Inspect it and read the Rules view, which shows rules applied directly and CSS inherited from ancestors (e.g., <body>). If the value is inherited from a parent, add a rule that overwrites it for this element. (7.1)
40
New cards
Code reading: .special { color: orange; } comes before em { color: hotpink; font-weight: bold; }. What color is <em class="special">, and what does DevTools show?
Orange. Class selectors are more specific than element selectors, so .special wins even though the em rule comes later. Inspecting the em shows the em rule's color crossed out. (7.1)
41
New cards
Scenario: width: 200px; padding: 10px; border: 2px solid. How much width does the box take up with content-box vs border-box?
content-box: 200 + 10 + 10 + 2 + 2 = 224px (padding and border added on). | border-box: exactly 200px (padding and border subtracted from the 200px). Check which one applies in the Layout view. (7.1)
42
New cards
Scenario: DevTools shows grid-template-columns: subgrid crossed out. What does it mean, and what should you check?
The browser you're testing in doesn't support the subgrid value. Browsers ignore CSS they don't understand: nothing breaks, but it isn't applied. Check the browser compatibility table on the property's MDN page. (7.1)
43
New cards
What does a crossed-out declaration in the Rules view tell you?
That declaration isn't being applied: either a more specific selector is overriding it (e.g., a class selector over an element selector), or its value is invalid or unsupported. (7.1)
44
New cards
MDN's steps when CSS isn't behaving as expected (in order)?
1) Take a step back from the problem | 2) Check for valid HTML and CSS (run both validators) | 3) Check the property and value are supported by the browser you're testing in | 4) Check whether something more specific is overriding your CSS | 5) Make a reduced test case (7.1)
45
New cards
How do you build a reduced test case?
1) If the markup is dynamically generated (e.g., by a CMS), make a static version: View Source, copy into CodePen, add the relevant CSS and JavaScript, and check the issue still shows | 2) Keep JavaScript only if removing it makes the issue go away, and then only the part that causes it | 3) Remove HTML that doesn't contribute to the issue | 4) Remove CSS that doesn't impact the issue (7.1)
46
New cards
Why make a reduced test case before asking for help?
Reducing the issue often reveals the cause, or lets you turn it on and off. If not, people are much more likely to help when you've already isolated exactly where it happens; comments in it show what you tried. It can also be filed as a browser bug report (e.g., on Mozilla's bugzilla). (7.1)