Small Group Tutorials

Here to help students catch up, keep up, and move ahead. Book a consultation here.

How to Master CSS :user-invalid in Punggol Tuition

Canal and bridge at Punggol Waterway Park with a runner in the foreground

When a learner can reproduce a familiar example but a small variation causes confusion, the problem is usually an incomplete model rather than a lack of effort. The fastest useful response is to expose the hidden state and test one boundary at a time.

CSS :user-invalid represents a form control whose value is invalid after the user has significantly interacted with it. It is designed to avoid the common problem of painting untouched required fields as errors the moment a page loads. The exact pre-submission timing may follow host-language and browser conventions, but Selectors Level 4 requires the state to be tied to invalidity and at least to match after an unsuccessful form-submission attempt until the user interacts again or resets the form. Mastery means separating :invalid from :user-invalid, relying on HTML constraints for validity, treating CSS as presentation rather than validation, and pairing visual styling with accessible messages and testable interaction paths. This guide begins with that mechanism, then develops it through worked traces, deliberate mistakes, explained practice and transfer decisions.

The aim is independent reasoning. A learner should be able to predict behaviour, locate the earliest wrong assumption, use a safe diagnostic procedure and defend a design choice in a new project.

Punggol families can use the guide in short sessions around homework, CCAs and rest. The activities are proposed learning exercises, not claims about a physical branch, timetable, class size, fee, school relationship or guaranteed result.

Use disposable data and repositories, preserve backups, and check version-sensitive details against the official source. Current documentation settles a technical contract; observation and explanation turn that contract into usable knowledge.

Find your next learning step

Choose the route that matches the present difficulty. Use the complete index for a systematic course.

Build the model

Chapters 1-4 . Begin here, then continue after the learner can predict, verify and explain.

Use the core tools

Chapters 5-8 . Begin here, then continue after the learner can predict, verify and explain.

Handle boundaries

Chapters 9-12 . Begin here, then continue after the learner can predict, verify and explain.

Debug and verify

Chapters 13-16 . Begin here, then continue after the learner can predict, verify and explain.

Transfer with judgment

Chapters 17-20 . Begin here, then continue after the learner can predict, verify and explain.

Open the full chapter index . Jump to capstone practice . Use the How Studying Works hub . Read the official documentation

CHAPTER 1 OF 20 . Build the model

1. Validity comes from the control contract

Back to contents

:user-invalid can only match an element that is invalid according to the host language validation rules. Treat that sentence as a testable model. A secure learner can point to the relevant input, name the operation, describe the resulting state and identify one observation that would prove the model incomplete.

The high-value mistake in this chapter is writing the selector without any required, type, pattern, range or custom validity rule. It matters because the output may look reasonable while the ownership, ordering, identity or safety rule is wrong. State the contract for Validity comes from the control contract, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence.

For the Validity comes from the control contract chapter on CSS :user-invalid, use a two-column trace during a short Punggol home session. On the left, write the predicted state for this exact mechanism before the tool runs. On the right, record the observation that bears on writing the selector without any required, type, pattern, range or custom validity rule. Explain the earliest difference with one causal sentence, then repeat only the smallest changed case.

Core worked example

<input id="email" type="email" required>
<style>input:user-invalid{border-color:#b3261e}</style>

Explained result. An empty or malformed required email can become user-invalid after the relevant interaction; CSS itself does not create the constraint. Check the boundary as well as the happy path: ask what happens with an empty input, a duplicate or tied value, an unsupported type, a missing path, a NULL, or a second reference to the same object. Only the relevant boundary should be kept; the list is a prompt for judgment, not a demand to force every case into every example.

Four purposeful transfer cases

Case 1: homework upload. Predict the rule using a required file description shows feedback after an attempted submission. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.

Reasoned route. Begin with “:user-invalid can only match an element that is invalid according to the host language validation rules.” Apply this procedure: State the contract for Validity comes from the control contract, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: An empty or malformed required email can become user-invalid after the relevant interaction; CSS itself does not create the constraint. For the homework upload, add one near-miss that exposes writing the selector without any required, type, pattern, range or custom validity rule. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.

Case 2: reading club form. Contrast the rule using an email field becomes user-invalid only after meaningful interaction. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.

Reasoned route. Begin with “:user-invalid can only match an element that is invalid according to the host language validation rules.” Apply this procedure: State the contract for Validity comes from the control contract, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: An empty or malformed required email can become user-invalid after the relevant interaction; CSS itself does not create the constraint. For the reading club form, add one near-miss that exposes writing the selector without any required, type, pattern, range or custom validity rule. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.

Case 3: science signup. Stress-test the rule using a number outside its min–max range receives a clear error state. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.

Reasoned route. Begin with “:user-invalid can only match an element that is invalid according to the host language validation rules.” Apply this procedure: State the contract for Validity comes from the control contract, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: An empty or malformed required email can become user-invalid after the relevant interaction; CSS itself does not create the constraint. For the science signup, add one near-miss that exposes writing the selector without any required, type, pattern, range or custom validity rule. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.

Case 4: CCA registration. Explain the rule using a required selection and consent checkbox are tested by keyboard. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.

Reasoned route. Begin with “:user-invalid can only match an element that is invalid according to the host language validation rules.” Apply this procedure: State the contract for Validity comes from the control contract, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: An empty or malformed required email can become user-invalid after the relevant interaction; CSS itself does not create the constraint. For the CCA registration, add one near-miss that exposes writing the selector without any required, type, pattern, range or custom validity rule. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.

Diagnostic route

  • Model check: ask the learner to draw or list the exact rows, fields, references, paths or states involved.
  • Boundary check: create the smallest input that triggers writing the selector without any required, type, pattern, range or custom validity rule.
  • Evidence check: separate a printed value from identity, ordering, ownership, type or repository state.
  • Repair check: use the reversible procedure “State the contract for Validity comes from the control contract, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence.” and record the first changed observation.
  • Transfer check: repeat the rule in a second context and identify what remains invariant.

A parent does not need to know the final CSS :user-invalid syntax. For this chapter, useful prompts are: “What did you expect from Validity comes from the control contract?”, “Which state changed first?”, “What evidence tests that prediction?”, and “Can the case exposing writing the selector without any required, type, pattern, range or custom validity rule be made smaller?” The learner, not the parent, should supply the technical explanation.

Practice with an explained answer

Question. Build a tiny library reservation with a reset clears user-interaction state and returns the form to neutral. Include one ordinary case, one boundary and one deliberate failure caused by writing the selector without any required, type, pattern, range or custom validity rule. Predict each result before using a tool, then report the first point where observation differs from prediction.

Answer guide. A strong response starts with the rule: :user-invalid can only match an element that is invalid according to the host language validation rules. It shows a trace, not only a final value. The ordinary case should demonstrate “An empty or malformed required email can become user-invalid after the relevant interaction; CSS itself does not create the constraint.” The boundary must exercise the same mechanism at an edge, and the deliberate failure must be repaired with: State the contract for Validity comes from the control contract, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. Other data choices are valid when the evidence supports the same causal chain.

Decision and transfer

For Validity comes from the control contract, separate the documented CSS :user-invalid mechanism from the project policy. State exactly what the technical contract guarantees, then state the project choice about validation, ordering, ownership, performance or recovery. Test whether the same distinction survives one transfer case, and keep stateful experiments disposable and backed up.

Previous chapter . Contents . Next chapter

CHAPTER 2 OF 20 . Build the model

2. User interaction distinguishes it from invalid

Back to contents

:invalid reflects current constraint validity, while :user-invalid waits for significant user interaction under the platform rules. Treat that sentence as a testable model. A secure learner can point to the relevant input, name the operation, describe the resulting state and identify one observation that would prove the model incomplete.

The high-value mistake in this chapter is assuming the two selectors are exact aliases. It matters because the output may look reasonable while the ownership, ordering, identity or safety rule is wrong. State the contract for User interaction distinguishes it from invalid, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence.

For the User interaction distinguishes it from invalid chapter on CSS :user-invalid, use a two-column trace during a short Punggol home session. On the left, write the predicted state for this exact mechanism before the tool runs. On the right, record the observation that bears on assuming the two selectors are exact aliases. Explain the earliest difference with one causal sentence, then repeat only the smallest changed case.

Core worked example

input:invalid{outline:1px solid #999}
input:user-invalid{outline:3px solid #b3261e}

Explained result. An untouched required field can match :invalid before it matches :user-invalid. Check the boundary as well as the happy path: ask what happens with an empty input, a duplicate or tied value, an unsupported type, a missing path, a NULL, or a second reference to the same object. Only the relevant boundary should be kept; the list is a prompt for judgment, not a demand to force every case into every example.

Four purposeful transfer cases

Case 1: science signup. Contrast the rule using a number outside its min–max range receives a clear error state. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.

Reasoned route. Begin with “:invalid reflects current constraint validity, while :user-invalid waits for significant user interaction under the platform rules.” Apply this procedure: State the contract for User interaction distinguishes it from invalid, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: An untouched required field can match :invalid before it matches :user-invalid. For the science signup, add one near-miss that exposes assuming the two selectors are exact aliases. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.

Case 2: CCA registration. Stress-test the rule using a required selection and consent checkbox are tested by keyboard. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.

Reasoned route. Begin with “:invalid reflects current constraint validity, while :user-invalid waits for significant user interaction under the platform rules.” Apply this procedure: State the contract for User interaction distinguishes it from invalid, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: An untouched required field can match :invalid before it matches :user-invalid. For the CCA registration, add one near-miss that exposes assuming the two selectors are exact aliases. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.

Case 3: family contact form. Explain the rule using a telephone pattern uses text, border and message cues together. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.

Reasoned route. Begin with “:invalid reflects current constraint validity, while :user-invalid waits for significant user interaction under the platform rules.” Apply this procedure: State the contract for User interaction distinguishes it from invalid, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: An untouched required field can match :invalid before it matches :user-invalid. For the family contact form, add one near-miss that exposes assuming the two selectors are exact aliases. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.

Case 4: library reservation. Transfer the rule using a reset clears user-interaction state and returns the form to neutral. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.

Reasoned route. Begin with “:invalid reflects current constraint validity, while :user-invalid waits for significant user interaction under the platform rules.” Apply this procedure: State the contract for User interaction distinguishes it from invalid, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: An untouched required field can match :invalid before it matches :user-invalid. For the library reservation, add one near-miss that exposes assuming the two selectors are exact aliases. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.

Diagnostic route

  • Model check: ask the learner to draw or list the exact rows, fields, references, paths or states involved.
  • Boundary check: create the smallest input that triggers assuming the two selectors are exact aliases.
  • Evidence check: separate a printed value from identity, ordering, ownership, type or repository state.
  • Repair check: use the reversible procedure “State the contract for User interaction distinguishes it from invalid, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence.” and record the first changed observation.
  • Transfer check: repeat the rule in a second context and identify what remains invariant.

A parent does not need to know the final CSS :user-invalid syntax. For this chapter, useful prompts are: “What did you expect from User interaction distinguishes it from invalid?”, “Which state changed first?”, “What evidence tests that prediction?”, and “Can the case exposing assuming the two selectors are exact aliases be made smaller?” The learner, not the parent, should supply the technical explanation.

Practice with an explained answer

Question. Build a tiny test laboratory with invalid, user-invalid, focus, blur, submit and reset paths are compared. Include one ordinary case, one boundary and one deliberate failure caused by assuming the two selectors are exact aliases. Predict each result before using a tool, then report the first point where observation differs from prediction.

Answer guide. A strong response starts with the rule: :invalid reflects current constraint validity, while :user-invalid waits for significant user interaction under the platform rules. It shows a trace, not only a final value. The ordinary case should demonstrate “An untouched required field can match :invalid before it matches :user-invalid.” The boundary must exercise the same mechanism at an edge, and the deliberate failure must be repaired with: State the contract for User interaction distinguishes it from invalid, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. Other data choices are valid when the evidence supports the same causal chain.

Decision and transfer

For User interaction distinguishes it from invalid, separate the documented CSS :user-invalid mechanism from the project policy. State exactly what the technical contract guarantees, then state the project choice about validation, ordering, ownership, performance or recovery. Test whether the same distinction survives one transfer case, and keep stateful experiments disposable and backed up.

Previous chapter . Contents . Next chapter

CHAPTER 3 OF 20 . Build the model

3. Failed submission is a required activation route

Back to contents

The specification requires matching after the user attempts to submit an invalid form, subject to subsequent interaction or reset rules. Treat that sentence as a testable model. A secure learner can point to the relevant input, name the operation, describe the resulting state and identify one observation that would prove the model incomplete.

The high-value mistake in this chapter is testing only blur behaviour and missing the dependable submission path. It matters because the output may look reasonable while the ownership, ordering, identity or safety rule is wrong. State the contract for Failed submission is a required activation route, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence.

For the Failed submission is a required activation route chapter on CSS :user-invalid, use a two-column trace during a short Punggol home session. On the left, write the predicted state for this exact mechanism before the tool runs. On the right, record the observation that bears on testing only blur behaviour and missing the dependable submission path. Explain the earliest difference with one causal sentence, then repeat only the smallest changed case.

Core worked example

<form><input required><button>Send</button></form>
<style>input:user-invalid{border-color:red}</style>

Explained result. Submitting the empty form gives the browser a clear route to expose the user-invalid state. Check the boundary as well as the happy path: ask what happens with an empty input, a duplicate or tied value, an unsupported type, a missing path, a NULL, or a second reference to the same object. Only the relevant boundary should be kept; the list is a prompt for judgment, not a demand to force every case into every example.

Four purposeful transfer cases

Case 1: family contact form. Stress-test the rule using a telephone pattern uses text, border and message cues together. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.

Reasoned route. Begin with “The specification requires matching after the user attempts to submit an invalid form, subject to subsequent interaction or reset rules.” Apply this procedure: State the contract for Failed submission is a required activation route, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: Submitting the empty form gives the browser a clear route to expose the user-invalid state. For the family contact form, add one near-miss that exposes testing only blur behaviour and missing the dependable submission path. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.

Case 2: library reservation. Explain the rule using a reset clears user-interaction state and returns the form to neutral. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.

Reasoned route. Begin with “The specification requires matching after the user attempts to submit an invalid form, subject to subsequent interaction or reset rules.” Apply this procedure: State the contract for Failed submission is a required activation route, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: Submitting the empty form gives the browser a clear route to expose the user-invalid state. For the library reservation, add one near-miss that exposes testing only blur behaviour and missing the dependable submission path. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.

Case 3: test laboratory. Transfer the rule using invalid, user-invalid, focus, blur, submit and reset paths are compared. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.

Reasoned route. Begin with “The specification requires matching after the user attempts to submit an invalid form, subject to subsequent interaction or reset rules.” Apply this procedure: State the contract for Failed submission is a required activation route, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: Submitting the empty form gives the browser a clear route to expose the user-invalid state. For the test laboratory, add one near-miss that exposes testing only blur behaviour and missing the dependable submission path. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.

Case 4: design decision. Predict the rule using :user-invalid is compared with :invalid, classes, aria-invalid and JavaScript validation. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.

Reasoned route. Begin with “The specification requires matching after the user attempts to submit an invalid form, subject to subsequent interaction or reset rules.” Apply this procedure: State the contract for Failed submission is a required activation route, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: Submitting the empty form gives the browser a clear route to expose the user-invalid state. For the design decision, add one near-miss that exposes testing only blur behaviour and missing the dependable submission path. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.

Diagnostic route

  • Model check: ask the learner to draw or list the exact rows, fields, references, paths or states involved.
  • Boundary check: create the smallest input that triggers testing only blur behaviour and missing the dependable submission path.
  • Evidence check: separate a printed value from identity, ordering, ownership, type or repository state.
  • Repair check: use the reversible procedure “State the contract for Failed submission is a required activation route, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence.” and record the first changed observation.
  • Transfer check: repeat the rule in a second context and identify what remains invariant.

A parent does not need to know the final CSS :user-invalid syntax. For this chapter, useful prompts are: “What did you expect from Failed submission is a required activation route?”, “Which state changed first?”, “What evidence tests that prediction?”, and “Can the case exposing testing only blur behaviour and missing the dependable submission path be made smaller?” The learner, not the parent, should supply the technical explanation.

Practice with an explained answer

Question. Build a tiny design decision with :user-invalid is compared with :invalid, classes, aria-invalid and JavaScript validation. Include one ordinary case, one boundary and one deliberate failure caused by testing only blur behaviour and missing the dependable submission path. Predict each result before using a tool, then report the first point where observation differs from prediction.

Answer guide. A strong response starts with the rule: The specification requires matching after the user attempts to submit an invalid form, subject to subsequent interaction or reset rules. It shows a trace, not only a final value. The ordinary case should demonstrate “Submitting the empty form gives the browser a clear route to expose the user-invalid state.” The boundary must exercise the same mechanism at an edge, and the deliberate failure must be repaired with: State the contract for Failed submission is a required activation route, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. Other data choices are valid when the evidence supports the same causal chain.

Decision and transfer

For Failed submission is a required activation route, separate the documented CSS :user-invalid mechanism from the project policy. State exactly what the technical contract guarantees, then state the project choice about validation, ordering, ownership, performance or recovery. Test whether the same distinction survives one transfer case, and keep stateful experiments disposable and backed up.

Previous chapter . Contents . Next chapter

CHAPTER 4 OF 20 . Build the model

4. Pre-submission timing may vary

Back to contents

Before submission, browsers may decide that changing a value and moving focus is significant interaction, but exact timing is not universally fixed by Selectors alone. Treat that sentence as a testable model. A secure learner can point to the relevant input, name the operation, describe the resulting state and identify one observation that would prove the model incomplete.

The high-value mistake in this chapter is promising one identical blur moment across every browser and input type. It matters because the output may look reasonable while the ownership, ordering, identity or safety rule is wrong. State the contract for Pre-submission timing may vary, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence.

For the Pre-submission timing may vary chapter on CSS :user-invalid, use a two-column trace during a short Punggol home session. On the left, write the predicted state for this exact mechanism before the tool runs. On the right, record the observation that bears on promising one identical blur moment across every browser and input type. Explain the earliest difference with one causal sentence, then repeat only the smallest changed case.

Core worked example

input:user-invalid{background:#fff4f2}

Explained result. The rule is portable as a state style, while tests must cover the target browsers interaction sequence. Check the boundary as well as the happy path: ask what happens with an empty input, a duplicate or tied value, an unsupported type, a missing path, a NULL, or a second reference to the same object. Only the relevant boundary should be kept; the list is a prompt for judgment, not a demand to force every case into every example.

Four purposeful transfer cases

Case 1: test laboratory. Explain the rule using invalid, user-invalid, focus, blur, submit and reset paths are compared. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.

Reasoned route. Begin with “Before submission, browsers may decide that changing a value and moving focus is significant interaction, but exact timing is not universally fixed by Selectors alone.” Apply this procedure: State the contract for Pre-submission timing may vary, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: The rule is portable as a state style, while tests must cover the target browsers interaction sequence. For the test laboratory, add one near-miss that exposes promising one identical blur moment across every browser and input type. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.

Case 2: design decision. Transfer the rule using :user-invalid is compared with :invalid, classes, aria-invalid and JavaScript validation. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.

Reasoned route. Begin with “Before submission, browsers may decide that changing a value and moving focus is significant interaction, but exact timing is not universally fixed by Selectors alone.” Apply this procedure: State the contract for Pre-submission timing may vary, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: The rule is portable as a state style, while tests must cover the target browsers interaction sequence. For the design decision, add one near-miss that exposes promising one identical blur moment across every browser and input type. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.

Case 3: homework upload. Predict the rule using a required file description shows feedback after an attempted submission. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.

Reasoned route. Begin with “Before submission, browsers may decide that changing a value and moving focus is significant interaction, but exact timing is not universally fixed by Selectors alone.” Apply this procedure: State the contract for Pre-submission timing may vary, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: The rule is portable as a state style, while tests must cover the target browsers interaction sequence. For the homework upload, add one near-miss that exposes promising one identical blur moment across every browser and input type. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.

Case 4: reading club form. Contrast the rule using an email field becomes user-invalid only after meaningful interaction. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.

Reasoned route. Begin with “Before submission, browsers may decide that changing a value and moving focus is significant interaction, but exact timing is not universally fixed by Selectors alone.” Apply this procedure: State the contract for Pre-submission timing may vary, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: The rule is portable as a state style, while tests must cover the target browsers interaction sequence. For the reading club form, add one near-miss that exposes promising one identical blur moment across every browser and input type. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.

Diagnostic route

  • Model check: ask the learner to draw or list the exact rows, fields, references, paths or states involved.
  • Boundary check: create the smallest input that triggers promising one identical blur moment across every browser and input type.
  • Evidence check: separate a printed value from identity, ordering, ownership, type or repository state.
  • Repair check: use the reversible procedure “State the contract for Pre-submission timing may vary, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence.” and record the first changed observation.
  • Transfer check: repeat the rule in a second context and identify what remains invariant.

A parent does not need to know the final CSS :user-invalid syntax. For this chapter, useful prompts are: “What did you expect from Pre-submission timing may vary?”, “Which state changed first?”, “What evidence tests that prediction?”, and “Can the case exposing promising one identical blur moment across every browser and input type be made smaller?” The learner, not the parent, should supply the technical explanation.

Practice with an explained answer

Question. Build a tiny homework upload with a required file description shows feedback after an attempted submission. Include one ordinary case, one boundary and one deliberate failure caused by promising one identical blur moment across every browser and input type. Predict each result before using a tool, then report the first point where observation differs from prediction.

Answer guide. A strong response starts with the rule: Before submission, browsers may decide that changing a value and moving focus is significant interaction, but exact timing is not universally fixed by Selectors alone. It shows a trace, not only a final value. The ordinary case should demonstrate “The rule is portable as a state style, while tests must cover the target browsers interaction sequence.” The boundary must exercise the same mechanism at an edge, and the deliberate failure must be repaired with: State the contract for Pre-submission timing may vary, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. Other data choices are valid when the evidence supports the same causal chain.

Decision and transfer

For Pre-submission timing may vary, separate the documented CSS :user-invalid mechanism from the project policy. State exactly what the technical contract guarantees, then state the project choice about validation, ordering, ownership, performance or recovery. Test whether the same distinction survives one transfer case, and keep stateful experiments disposable and backed up.

Previous chapter . Contents . Next chapter

CHAPTER 5 OF 20 . Use the core tools

5. A required empty field is invalid

Back to contents

The HTML required constraint makes a supported empty control invalid, but user-invalid presentation still depends on user interaction. Treat that sentence as a testable model. A secure learner can point to the relevant input, name the operation, describe the resulting state and identify one observation that would prove the model incomplete.

The high-value mistake in this chapter is blaming CSS when the control is optional and therefore valid while empty. It matters because the output may look reasonable while the ownership, ordering, identity or safety rule is wrong. State the contract for A required empty field is invalid, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence.

For the A required empty field is invalid chapter on CSS :user-invalid, use a two-column trace during a short Punggol home session. On the left, write the predicted state for this exact mechanism before the tool runs. On the right, record the observation that bears on blaming CSS when the control is optional and therefore valid while empty. Explain the earliest difference with one causal sentence, then repeat only the smallest changed case.

Core worked example

<input name="name" required>
<style>input:user-invalid{border-inline-start:4px solid #b3261e}</style>

Explained result. The required attribute supplies the missing-value constraint and the selector supplies delayed presentation. Check the boundary as well as the happy path: ask what happens with an empty input, a duplicate or tied value, an unsupported type, a missing path, a NULL, or a second reference to the same object. Only the relevant boundary should be kept; the list is a prompt for judgment, not a demand to force every case into every example.

Four purposeful transfer cases

Case 1: homework upload. Transfer the rule using a required file description shows feedback after an attempted submission. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.

Reasoned route. Begin with “The HTML required constraint makes a supported empty control invalid, but user-invalid presentation still depends on user interaction.” Apply this procedure: State the contract for A required empty field is invalid, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: The required attribute supplies the missing-value constraint and the selector supplies delayed presentation. For the homework upload, add one near-miss that exposes blaming CSS when the control is optional and therefore valid while empty. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.

Case 2: reading club form. Predict the rule using an email field becomes user-invalid only after meaningful interaction. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.

Reasoned route. Begin with “The HTML required constraint makes a supported empty control invalid, but user-invalid presentation still depends on user interaction.” Apply this procedure: State the contract for A required empty field is invalid, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: The required attribute supplies the missing-value constraint and the selector supplies delayed presentation. For the reading club form, add one near-miss that exposes blaming CSS when the control is optional and therefore valid while empty. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.

Case 3: science signup. Contrast the rule using a number outside its min–max range receives a clear error state. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.

Reasoned route. Begin with “The HTML required constraint makes a supported empty control invalid, but user-invalid presentation still depends on user interaction.” Apply this procedure: State the contract for A required empty field is invalid, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: The required attribute supplies the missing-value constraint and the selector supplies delayed presentation. For the science signup, add one near-miss that exposes blaming CSS when the control is optional and therefore valid while empty. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.

Case 4: CCA registration. Stress-test the rule using a required selection and consent checkbox are tested by keyboard. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.

Reasoned route. Begin with “The HTML required constraint makes a supported empty control invalid, but user-invalid presentation still depends on user interaction.” Apply this procedure: State the contract for A required empty field is invalid, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: The required attribute supplies the missing-value constraint and the selector supplies delayed presentation. For the CCA registration, add one near-miss that exposes blaming CSS when the control is optional and therefore valid while empty. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.

Diagnostic route

  • Model check: ask the learner to draw or list the exact rows, fields, references, paths or states involved.
  • Boundary check: create the smallest input that triggers blaming CSS when the control is optional and therefore valid while empty.
  • Evidence check: separate a printed value from identity, ordering, ownership, type or repository state.
  • Repair check: use the reversible procedure “State the contract for A required empty field is invalid, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence.” and record the first changed observation.
  • Transfer check: repeat the rule in a second context and identify what remains invariant.

A parent does not need to know the final CSS :user-invalid syntax. For this chapter, useful prompts are: “What did you expect from A required empty field is invalid?”, “Which state changed first?”, “What evidence tests that prediction?”, and “Can the case exposing blaming CSS when the control is optional and therefore valid while empty be made smaller?” The learner, not the parent, should supply the technical explanation.

Practice with an explained answer

Question. Build a tiny reading club form with an email field becomes user-invalid only after meaningful interaction. Include one ordinary case, one boundary and one deliberate failure caused by blaming CSS when the control is optional and therefore valid while empty. Predict each result before using a tool, then report the first point where observation differs from prediction.

Answer guide. A strong response starts with the rule: The HTML required constraint makes a supported empty control invalid, but user-invalid presentation still depends on user interaction. It shows a trace, not only a final value. The ordinary case should demonstrate “The required attribute supplies the missing-value constraint and the selector supplies delayed presentation.” The boundary must exercise the same mechanism at an edge, and the deliberate failure must be repaired with: State the contract for A required empty field is invalid, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. Other data choices are valid when the evidence supports the same causal chain.

Decision and transfer

For A required empty field is invalid, separate the documented CSS :user-invalid mechanism from the project policy. State exactly what the technical contract guarantees, then state the project choice about validation, ordering, ownership, performance or recovery. Test whether the same distinction survives one transfer case, and keep stateful experiments disposable and backed up.

Previous chapter . Contents . Next chapter

CHAPTER 6 OF 20 . Use the core tools

6. Type mismatch can drive the state

Back to contents

Input types such as email and url contribute built-in validity rules when the value does not satisfy their syntax. Treat that sentence as a testable model. A secure learner can point to the relevant input, name the operation, describe the resulting state and identify one observation that would prove the model incomplete.

The high-value mistake in this chapter is using type=text and expecting the browser to recognise an email format automatically. It matters because the output may look reasonable while the ownership, ordering, identity or safety rule is wrong. State the contract for Type mismatch can drive the state, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence.

For the Type mismatch can drive the state chapter on CSS :user-invalid, use a two-column trace during a short Punggol home session. On the left, write the predicted state for this exact mechanism before the tool runs. On the right, record the observation that bears on using type=text and expecting the browser to recognise an email format automatically. Explain the earliest difference with one causal sentence, then repeat only the smallest changed case.

Core worked example

<input type="email" required value="not-an-email">

Explained result. The value has a type mismatch; after significant interaction it can match :user-invalid. Check the boundary as well as the happy path: ask what happens with an empty input, a duplicate or tied value, an unsupported type, a missing path, a NULL, or a second reference to the same object. Only the relevant boundary should be kept; the list is a prompt for judgment, not a demand to force every case into every example.

Four purposeful transfer cases

Case 1: science signup. Predict the rule using a number outside its min–max range receives a clear error state. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.

Reasoned route. Begin with “Input types such as email and url contribute built-in validity rules when the value does not satisfy their syntax.” Apply this procedure: State the contract for Type mismatch can drive the state, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: The value has a type mismatch; after significant interaction it can match :user-invalid. For the science signup, add one near-miss that exposes using type=text and expecting the browser to recognise an email format automatically. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.

Case 2: CCA registration. Contrast the rule using a required selection and consent checkbox are tested by keyboard. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.

Reasoned route. Begin with “Input types such as email and url contribute built-in validity rules when the value does not satisfy their syntax.” Apply this procedure: State the contract for Type mismatch can drive the state, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: The value has a type mismatch; after significant interaction it can match :user-invalid. For the CCA registration, add one near-miss that exposes using type=text and expecting the browser to recognise an email format automatically. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.

Case 3: family contact form. Stress-test the rule using a telephone pattern uses text, border and message cues together. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.

Reasoned route. Begin with “Input types such as email and url contribute built-in validity rules when the value does not satisfy their syntax.” Apply this procedure: State the contract for Type mismatch can drive the state, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: The value has a type mismatch; after significant interaction it can match :user-invalid. For the family contact form, add one near-miss that exposes using type=text and expecting the browser to recognise an email format automatically. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.

Case 4: library reservation. Explain the rule using a reset clears user-interaction state and returns the form to neutral. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.

Reasoned route. Begin with “Input types such as email and url contribute built-in validity rules when the value does not satisfy their syntax.” Apply this procedure: State the contract for Type mismatch can drive the state, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: The value has a type mismatch; after significant interaction it can match :user-invalid. For the library reservation, add one near-miss that exposes using type=text and expecting the browser to recognise an email format automatically. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.

Diagnostic route

  • Model check: ask the learner to draw or list the exact rows, fields, references, paths or states involved.
  • Boundary check: create the smallest input that triggers using type=text and expecting the browser to recognise an email format automatically.
  • Evidence check: separate a printed value from identity, ordering, ownership, type or repository state.
  • Repair check: use the reversible procedure “State the contract for Type mismatch can drive the state, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence.” and record the first changed observation.
  • Transfer check: repeat the rule in a second context and identify what remains invariant.

A parent does not need to know the final CSS :user-invalid syntax. For this chapter, useful prompts are: “What did you expect from Type mismatch can drive the state?”, “Which state changed first?”, “What evidence tests that prediction?”, and “Can the case exposing using type=text and expecting the browser to recognise an email format automatically be made smaller?” The learner, not the parent, should supply the technical explanation.

Practice with an explained answer

Question. Build a tiny science signup with a number outside its min–max range receives a clear error state. Include one ordinary case, one boundary and one deliberate failure caused by using type=text and expecting the browser to recognise an email format automatically. Predict each result before using a tool, then report the first point where observation differs from prediction.

Answer guide. A strong response starts with the rule: Input types such as email and url contribute built-in validity rules when the value does not satisfy their syntax. It shows a trace, not only a final value. The ordinary case should demonstrate “The value has a type mismatch; after significant interaction it can match :user-invalid.” The boundary must exercise the same mechanism at an edge, and the deliberate failure must be repaired with: State the contract for Type mismatch can drive the state, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. Other data choices are valid when the evidence supports the same causal chain.

Decision and transfer

For Type mismatch can drive the state, separate the documented CSS :user-invalid mechanism from the project policy. State exactly what the technical contract guarantees, then state the project choice about validation, ordering, ownership, performance or recovery. Test whether the same distinction survives one transfer case, and keep stateful experiments disposable and backed up.

Previous chapter . Contents . Next chapter

CHAPTER 7 OF 20 . Use the core tools

7. Range constraints are distinct evidence

Back to contents

Number and date-like controls can be invalid because values fall below min, above max or violate step. Treat that sentence as a testable model. A secure learner can point to the relevant input, name the operation, describe the resulting state and identify one observation that would prove the model incomplete.

The high-value mistake in this chapter is showing one generic error message that says required when the actual value is out of range. It matters because the output may look reasonable while the ownership, ordering, identity or safety rule is wrong. State the contract for Range constraints are distinct evidence, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence.

For the Range constraints are distinct evidence chapter on CSS :user-invalid, use a two-column trace during a short Punggol home session. On the left, write the predicted state for this exact mechanism before the tool runs. On the right, record the observation that bears on showing one generic error message that says required when the actual value is out of range. Explain the earliest difference with one causal sentence, then repeat only the smallest changed case.

Core worked example

<input type="number" min="0" max="10" value="11">

Explained result. The control is invalid because 11 exceeds max, so the nearby message should explain the actual range. Check the boundary as well as the happy path: ask what happens with an empty input, a duplicate or tied value, an unsupported type, a missing path, a NULL, or a second reference to the same object. Only the relevant boundary should be kept; the list is a prompt for judgment, not a demand to force every case into every example.

Four purposeful transfer cases

Case 1: family contact form. Contrast the rule using a telephone pattern uses text, border and message cues together. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.

Reasoned route. Begin with “Number and date-like controls can be invalid because values fall below min, above max or violate step.” Apply this procedure: State the contract for Range constraints are distinct evidence, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: The control is invalid because 11 exceeds max, so the nearby message should explain the actual range. For the family contact form, add one near-miss that exposes showing one generic error message that says required when the actual value is out of range. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.

Case 2: library reservation. Stress-test the rule using a reset clears user-interaction state and returns the form to neutral. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.

Reasoned route. Begin with “Number and date-like controls can be invalid because values fall below min, above max or violate step.” Apply this procedure: State the contract for Range constraints are distinct evidence, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: The control is invalid because 11 exceeds max, so the nearby message should explain the actual range. For the library reservation, add one near-miss that exposes showing one generic error message that says required when the actual value is out of range. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.

Case 3: test laboratory. Explain the rule using invalid, user-invalid, focus, blur, submit and reset paths are compared. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.

Reasoned route. Begin with “Number and date-like controls can be invalid because values fall below min, above max or violate step.” Apply this procedure: State the contract for Range constraints are distinct evidence, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: The control is invalid because 11 exceeds max, so the nearby message should explain the actual range. For the test laboratory, add one near-miss that exposes showing one generic error message that says required when the actual value is out of range. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.

Case 4: design decision. Transfer the rule using :user-invalid is compared with :invalid, classes, aria-invalid and JavaScript validation. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.

Reasoned route. Begin with “Number and date-like controls can be invalid because values fall below min, above max or violate step.” Apply this procedure: State the contract for Range constraints are distinct evidence, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: The control is invalid because 11 exceeds max, so the nearby message should explain the actual range. For the design decision, add one near-miss that exposes showing one generic error message that says required when the actual value is out of range. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.

Diagnostic route

  • Model check: ask the learner to draw or list the exact rows, fields, references, paths or states involved.
  • Boundary check: create the smallest input that triggers showing one generic error message that says required when the actual value is out of range.
  • Evidence check: separate a printed value from identity, ordering, ownership, type or repository state.
  • Repair check: use the reversible procedure “State the contract for Range constraints are distinct evidence, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence.” and record the first changed observation.
  • Transfer check: repeat the rule in a second context and identify what remains invariant.

A parent does not need to know the final CSS :user-invalid syntax. For this chapter, useful prompts are: “What did you expect from Range constraints are distinct evidence?”, “Which state changed first?”, “What evidence tests that prediction?”, and “Can the case exposing showing one generic error message that says required when the actual value is out of range be made smaller?” The learner, not the parent, should supply the technical explanation.

Practice with an explained answer

Question. Build a tiny CCA registration with a required selection and consent checkbox are tested by keyboard. Include one ordinary case, one boundary and one deliberate failure caused by showing one generic error message that says required when the actual value is out of range. Predict each result before using a tool, then report the first point where observation differs from prediction.

Answer guide. A strong response starts with the rule: Number and date-like controls can be invalid because values fall below min, above max or violate step. It shows a trace, not only a final value. The ordinary case should demonstrate “The control is invalid because 11 exceeds max, so the nearby message should explain the actual range.” The boundary must exercise the same mechanism at an edge, and the deliberate failure must be repaired with: State the contract for Range constraints are distinct evidence, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. Other data choices are valid when the evidence supports the same causal chain.

Decision and transfer

For Range constraints are distinct evidence, separate the documented CSS :user-invalid mechanism from the project policy. State exactly what the technical contract guarantees, then state the project choice about validation, ordering, ownership, performance or recovery. Test whether the same distinction survives one transfer case, and keep stateful experiments disposable and backed up.

Previous chapter . Contents . Next chapter

CHAPTER 8 OF 20 . Use the core tools

8. Pattern mismatch applies to non-empty values

Back to contents

The pattern attribute constrains appropriate text-like values, while an empty value is not made invalid by pattern alone unless required also applies. Treat that sentence as a testable model. A secure learner can point to the relevant input, name the operation, describe the resulting state and identify one observation that would prove the model incomplete.

The high-value mistake in this chapter is expecting pattern to make an optional empty input fail. It matters because the output may look reasonable while the ownership, ordering, identity or safety rule is wrong. State the contract for Pattern mismatch applies to non-empty values, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence.

For the Pattern mismatch applies to non-empty values chapter on CSS :user-invalid, use a two-column trace during a short Punggol home session. On the left, write the predicted state for this exact mechanism before the tool runs. On the right, record the observation that bears on expecting pattern to make an optional empty input fail. Explain the earliest difference with one causal sentence, then repeat only the smallest changed case.

Core worked example

<input pattern="[A-Z]{3}" required>

Explained result. Required handles emptiness; pattern handles a non-empty value that is not exactly three uppercase letters. Check the boundary as well as the happy path: ask what happens with an empty input, a duplicate or tied value, an unsupported type, a missing path, a NULL, or a second reference to the same object. Only the relevant boundary should be kept; the list is a prompt for judgment, not a demand to force every case into every example.

Four purposeful transfer cases

Case 1: test laboratory. Stress-test the rule using invalid, user-invalid, focus, blur, submit and reset paths are compared. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.

Reasoned route. Begin with “The pattern attribute constrains appropriate text-like values, while an empty value is not made invalid by pattern alone unless required also applies.” Apply this procedure: State the contract for Pattern mismatch applies to non-empty values, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: Required handles emptiness; pattern handles a non-empty value that is not exactly three uppercase letters. For the test laboratory, add one near-miss that exposes expecting pattern to make an optional empty input fail. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.

Case 2: design decision. Explain the rule using :user-invalid is compared with :invalid, classes, aria-invalid and JavaScript validation. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.

Reasoned route. Begin with “The pattern attribute constrains appropriate text-like values, while an empty value is not made invalid by pattern alone unless required also applies.” Apply this procedure: State the contract for Pattern mismatch applies to non-empty values, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: Required handles emptiness; pattern handles a non-empty value that is not exactly three uppercase letters. For the design decision, add one near-miss that exposes expecting pattern to make an optional empty input fail. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.

Case 3: homework upload. Transfer the rule using a required file description shows feedback after an attempted submission. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.

Reasoned route. Begin with “The pattern attribute constrains appropriate text-like values, while an empty value is not made invalid by pattern alone unless required also applies.” Apply this procedure: State the contract for Pattern mismatch applies to non-empty values, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: Required handles emptiness; pattern handles a non-empty value that is not exactly three uppercase letters. For the homework upload, add one near-miss that exposes expecting pattern to make an optional empty input fail. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.

Case 4: reading club form. Predict the rule using an email field becomes user-invalid only after meaningful interaction. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.

Reasoned route. Begin with “The pattern attribute constrains appropriate text-like values, while an empty value is not made invalid by pattern alone unless required also applies.” Apply this procedure: State the contract for Pattern mismatch applies to non-empty values, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: Required handles emptiness; pattern handles a non-empty value that is not exactly three uppercase letters. For the reading club form, add one near-miss that exposes expecting pattern to make an optional empty input fail. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.

Diagnostic route

  • Model check: ask the learner to draw or list the exact rows, fields, references, paths or states involved.
  • Boundary check: create the smallest input that triggers expecting pattern to make an optional empty input fail.
  • Evidence check: separate a printed value from identity, ordering, ownership, type or repository state.
  • Repair check: use the reversible procedure “State the contract for Pattern mismatch applies to non-empty values, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence.” and record the first changed observation.
  • Transfer check: repeat the rule in a second context and identify what remains invariant.

A parent does not need to know the final CSS :user-invalid syntax. For this chapter, useful prompts are: “What did you expect from Pattern mismatch applies to non-empty values?”, “Which state changed first?”, “What evidence tests that prediction?”, and “Can the case exposing expecting pattern to make an optional empty input fail be made smaller?” The learner, not the parent, should supply the technical explanation.

Practice with an explained answer

Question. Build a tiny family contact form with a telephone pattern uses text, border and message cues together. Include one ordinary case, one boundary and one deliberate failure caused by expecting pattern to make an optional empty input fail. Predict each result before using a tool, then report the first point where observation differs from prediction.

Answer guide. A strong response starts with the rule: The pattern attribute constrains appropriate text-like values, while an empty value is not made invalid by pattern alone unless required also applies. It shows a trace, not only a final value. The ordinary case should demonstrate “Required handles emptiness; pattern handles a non-empty value that is not exactly three uppercase letters.” The boundary must exercise the same mechanism at an edge, and the deliberate failure must be repaired with: State the contract for Pattern mismatch applies to non-empty values, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. Other data choices are valid when the evidence supports the same causal chain.

Decision and transfer

For Pattern mismatch applies to non-empty values, separate the documented CSS :user-invalid mechanism from the project policy. State exactly what the technical contract guarantees, then state the project choice about validation, ordering, ownership, performance or recovery. Test whether the same distinction survives one transfer case, and keep stateful experiments disposable and backed up.

Previous chapter . Contents . Next chapter

CHAPTER 9 OF 20 . Handle boundaries

9. Custom validity integrates with the same model

Back to contents

JavaScript setCustomValidity can make a control invalid, allowing the user-invalid selector to present that state after interaction. Treat that sentence as a testable model. A secure learner can point to the relevant input, name the operation, describe the resulting state and identify one observation that would prove the model incomplete.

The high-value mistake in this chapter is adding a red class while leaving the browser validity model unchanged. It matters because the output may look reasonable while the ownership, ordering, identity or safety rule is wrong. State the contract for Custom validity integrates with the same model, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence.

For the Custom validity integrates with the same model chapter on CSS :user-invalid, use a two-column trace during a short Punggol home session. On the left, write the predicted state for this exact mechanism before the tool runs. On the right, record the observation that bears on adding a red class while leaving the browser validity model unchanged. Explain the earliest difference with one causal sentence, then repeat only the smallest changed case.

Core worked example

const input=document.querySelector('input');
input.setCustomValidity('Code already used');

Explained result. The control now has a custom error in its ValidityState; clearing with an empty message restores validity when other constraints pass. Check the boundary as well as the happy path: ask what happens with an empty input, a duplicate or tied value, an unsupported type, a missing path, a NULL, or a second reference to the same object. Only the relevant boundary should be kept; the list is a prompt for judgment, not a demand to force every case into every example.

Four purposeful transfer cases

Case 1: homework upload. Explain the rule using a required file description shows feedback after an attempted submission. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.

Reasoned route. Begin with “JavaScript setCustomValidity can make a control invalid, allowing the user-invalid selector to present that state after interaction.” Apply this procedure: State the contract for Custom validity integrates with the same model, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: The control now has a custom error in its ValidityState; clearing with an empty message restores validity when other constraints pass. For the homework upload, add one near-miss that exposes adding a red class while leaving the browser validity model unchanged. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.

Case 2: reading club form. Transfer the rule using an email field becomes user-invalid only after meaningful interaction. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.

Reasoned route. Begin with “JavaScript setCustomValidity can make a control invalid, allowing the user-invalid selector to present that state after interaction.” Apply this procedure: State the contract for Custom validity integrates with the same model, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: The control now has a custom error in its ValidityState; clearing with an empty message restores validity when other constraints pass. For the reading club form, add one near-miss that exposes adding a red class while leaving the browser validity model unchanged. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.

Case 3: science signup. Predict the rule using a number outside its min–max range receives a clear error state. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.

Reasoned route. Begin with “JavaScript setCustomValidity can make a control invalid, allowing the user-invalid selector to present that state after interaction.” Apply this procedure: State the contract for Custom validity integrates with the same model, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: The control now has a custom error in its ValidityState; clearing with an empty message restores validity when other constraints pass. For the science signup, add one near-miss that exposes adding a red class while leaving the browser validity model unchanged. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.

Case 4: CCA registration. Contrast the rule using a required selection and consent checkbox are tested by keyboard. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.

Reasoned route. Begin with “JavaScript setCustomValidity can make a control invalid, allowing the user-invalid selector to present that state after interaction.” Apply this procedure: State the contract for Custom validity integrates with the same model, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: The control now has a custom error in its ValidityState; clearing with an empty message restores validity when other constraints pass. For the CCA registration, add one near-miss that exposes adding a red class while leaving the browser validity model unchanged. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.

Diagnostic route

  • Model check: ask the learner to draw or list the exact rows, fields, references, paths or states involved.
  • Boundary check: create the smallest input that triggers adding a red class while leaving the browser validity model unchanged.
  • Evidence check: separate a printed value from identity, ordering, ownership, type or repository state.
  • Repair check: use the reversible procedure “State the contract for Custom validity integrates with the same model, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence.” and record the first changed observation.
  • Transfer check: repeat the rule in a second context and identify what remains invariant.

A parent does not need to know the final CSS :user-invalid syntax. For this chapter, useful prompts are: “What did you expect from Custom validity integrates with the same model?”, “Which state changed first?”, “What evidence tests that prediction?”, and “Can the case exposing adding a red class while leaving the browser validity model unchanged be made smaller?” The learner, not the parent, should supply the technical explanation.

Practice with an explained answer

Question. Build a tiny library reservation with a reset clears user-interaction state and returns the form to neutral. Include one ordinary case, one boundary and one deliberate failure caused by adding a red class while leaving the browser validity model unchanged. Predict each result before using a tool, then report the first point where observation differs from prediction.

Answer guide. A strong response starts with the rule: JavaScript setCustomValidity can make a control invalid, allowing the user-invalid selector to present that state after interaction. It shows a trace, not only a final value. The ordinary case should demonstrate “The control now has a custom error in its ValidityState; clearing with an empty message restores validity when other constraints pass.” The boundary must exercise the same mechanism at an edge, and the deliberate failure must be repaired with: State the contract for Custom validity integrates with the same model, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. Other data choices are valid when the evidence supports the same causal chain.

Decision and transfer

For Custom validity integrates with the same model, separate the documented CSS :user-invalid mechanism from the project policy. State exactly what the technical contract guarantees, then state the project choice about validation, ordering, ownership, performance or recovery. Test whether the same distinction survives one transfer case, and keep stateful experiments disposable and backed up.

Previous chapter . Contents . Next chapter

CHAPTER 10 OF 20 . Handle boundaries

10. CSS does not replace validation logic

Back to contents

:user-invalid styles a state; it does not sanitize data, protect a server or decide business rules. Treat that sentence as a testable model. A secure learner can point to the relevant input, name the operation, describe the resulting state and identify one observation that would prove the model incomplete.

The high-value mistake in this chapter is treating a green border as proof that submitted data is safe. It matters because the output may look reasonable while the ownership, ordering, identity or safety rule is wrong. State the contract for CSS does not replace validation logic, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence.

For the CSS does not replace validation logic chapter on CSS :user-invalid, use a two-column trace during a short Punggol home session. On the left, write the predicted state for this exact mechanism before the tool runs. On the right, record the observation that bears on treating a green border as proof that submitted data is safe. Explain the earliest difference with one causal sentence, then repeat only the smallest changed case.

Core worked example

input:user-invalid{border-color:#b3261e}

Explained result. Client-side presentation helps the user, while server-side validation and domain checks remain mandatory. Check the boundary as well as the happy path: ask what happens with an empty input, a duplicate or tied value, an unsupported type, a missing path, a NULL, or a second reference to the same object. Only the relevant boundary should be kept; the list is a prompt for judgment, not a demand to force every case into every example.

Four purposeful transfer cases

Case 1: science signup. Transfer the rule using a number outside its min–max range receives a clear error state. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.

Reasoned route. Begin with “:user-invalid styles a state; it does not sanitize data, protect a server or decide business rules.” Apply this procedure: State the contract for CSS does not replace validation logic, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: Client-side presentation helps the user, while server-side validation and domain checks remain mandatory. For the science signup, add one near-miss that exposes treating a green border as proof that submitted data is safe. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.

Case 2: CCA registration. Predict the rule using a required selection and consent checkbox are tested by keyboard. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.

Reasoned route. Begin with “:user-invalid styles a state; it does not sanitize data, protect a server or decide business rules.” Apply this procedure: State the contract for CSS does not replace validation logic, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: Client-side presentation helps the user, while server-side validation and domain checks remain mandatory. For the CCA registration, add one near-miss that exposes treating a green border as proof that submitted data is safe. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.

Case 3: family contact form. Contrast the rule using a telephone pattern uses text, border and message cues together. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.

Reasoned route. Begin with “:user-invalid styles a state; it does not sanitize data, protect a server or decide business rules.” Apply this procedure: State the contract for CSS does not replace validation logic, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: Client-side presentation helps the user, while server-side validation and domain checks remain mandatory. For the family contact form, add one near-miss that exposes treating a green border as proof that submitted data is safe. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.

Case 4: library reservation. Stress-test the rule using a reset clears user-interaction state and returns the form to neutral. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.

Reasoned route. Begin with “:user-invalid styles a state; it does not sanitize data, protect a server or decide business rules.” Apply this procedure: State the contract for CSS does not replace validation logic, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: Client-side presentation helps the user, while server-side validation and domain checks remain mandatory. For the library reservation, add one near-miss that exposes treating a green border as proof that submitted data is safe. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.

Diagnostic route

  • Model check: ask the learner to draw or list the exact rows, fields, references, paths or states involved.
  • Boundary check: create the smallest input that triggers treating a green border as proof that submitted data is safe.
  • Evidence check: separate a printed value from identity, ordering, ownership, type or repository state.
  • Repair check: use the reversible procedure “State the contract for CSS does not replace validation logic, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence.” and record the first changed observation.
  • Transfer check: repeat the rule in a second context and identify what remains invariant.

A parent does not need to know the final CSS :user-invalid syntax. For this chapter, useful prompts are: “What did you expect from CSS does not replace validation logic?”, “Which state changed first?”, “What evidence tests that prediction?”, and “Can the case exposing treating a green border as proof that submitted data is safe be made smaller?” The learner, not the parent, should supply the technical explanation.

Practice with an explained answer

Question. Build a tiny test laboratory with invalid, user-invalid, focus, blur, submit and reset paths are compared. Include one ordinary case, one boundary and one deliberate failure caused by treating a green border as proof that submitted data is safe. Predict each result before using a tool, then report the first point where observation differs from prediction.

Answer guide. A strong response starts with the rule: :user-invalid styles a state; it does not sanitize data, protect a server or decide business rules. It shows a trace, not only a final value. The ordinary case should demonstrate “Client-side presentation helps the user, while server-side validation and domain checks remain mandatory.” The boundary must exercise the same mechanism at an edge, and the deliberate failure must be repaired with: State the contract for CSS does not replace validation logic, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. Other data choices are valid when the evidence supports the same causal chain.

Decision and transfer

For CSS does not replace validation logic, separate the documented CSS :user-invalid mechanism from the project policy. State exactly what the technical contract guarantees, then state the project choice about validation, ordering, ownership, performance or recovery. Test whether the same distinction survives one transfer case, and keep stateful experiments disposable and backed up.

Previous chapter . Contents . Next chapter

CHAPTER 11 OF 20 . Handle boundaries

11. Do not rely on colour alone

Back to contents

Accessible error treatment should combine colour with text, shape, iconography or another cue and maintain readable contrast. Treat that sentence as a testable model. A secure learner can point to the relevant input, name the operation, describe the resulting state and identify one observation that would prove the model incomplete.

The high-value mistake in this chapter is using only a subtle red tint that some users cannot perceive. It matters because the output may look reasonable while the ownership, ordering, identity or safety rule is wrong. State the contract for Do not rely on colour alone, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence.

For the Do not rely on colour alone chapter on CSS :user-invalid, use a two-column trace during a short Punggol home session. On the left, write the predicted state for this exact mechanism before the tool runs. On the right, record the observation that bears on using only a subtle red tint that some users cannot perceive. Explain the earliest difference with one causal sentence, then repeat only the smallest changed case.

Core worked example

input:user-invalid{border:3px solid #8b1e1e}
input:user-invalid + .error{font-weight:700}

Explained result. The stronger boundary and explicit message provide cues beyond hue. Check the boundary as well as the happy path: ask what happens with an empty input, a duplicate or tied value, an unsupported type, a missing path, a NULL, or a second reference to the same object. Only the relevant boundary should be kept; the list is a prompt for judgment, not a demand to force every case into every example.

Four purposeful transfer cases

Case 1: family contact form. Predict the rule using a telephone pattern uses text, border and message cues together. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.

Reasoned route. Begin with “Accessible error treatment should combine colour with text, shape, iconography or another cue and maintain readable contrast.” Apply this procedure: State the contract for Do not rely on colour alone, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: The stronger boundary and explicit message provide cues beyond hue. For the family contact form, add one near-miss that exposes using only a subtle red tint that some users cannot perceive. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.

Case 2: library reservation. Contrast the rule using a reset clears user-interaction state and returns the form to neutral. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.

Reasoned route. Begin with “Accessible error treatment should combine colour with text, shape, iconography or another cue and maintain readable contrast.” Apply this procedure: State the contract for Do not rely on colour alone, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: The stronger boundary and explicit message provide cues beyond hue. For the library reservation, add one near-miss that exposes using only a subtle red tint that some users cannot perceive. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.

Case 3: test laboratory. Stress-test the rule using invalid, user-invalid, focus, blur, submit and reset paths are compared. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.

Reasoned route. Begin with “Accessible error treatment should combine colour with text, shape, iconography or another cue and maintain readable contrast.” Apply this procedure: State the contract for Do not rely on colour alone, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: The stronger boundary and explicit message provide cues beyond hue. For the test laboratory, add one near-miss that exposes using only a subtle red tint that some users cannot perceive. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.

Case 4: design decision. Explain the rule using :user-invalid is compared with :invalid, classes, aria-invalid and JavaScript validation. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.

Reasoned route. Begin with “Accessible error treatment should combine colour with text, shape, iconography or another cue and maintain readable contrast.” Apply this procedure: State the contract for Do not rely on colour alone, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: The stronger boundary and explicit message provide cues beyond hue. For the design decision, add one near-miss that exposes using only a subtle red tint that some users cannot perceive. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.

Diagnostic route

  • Model check: ask the learner to draw or list the exact rows, fields, references, paths or states involved.
  • Boundary check: create the smallest input that triggers using only a subtle red tint that some users cannot perceive.
  • Evidence check: separate a printed value from identity, ordering, ownership, type or repository state.
  • Repair check: use the reversible procedure “State the contract for Do not rely on colour alone, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence.” and record the first changed observation.
  • Transfer check: repeat the rule in a second context and identify what remains invariant.

A parent does not need to know the final CSS :user-invalid syntax. For this chapter, useful prompts are: “What did you expect from Do not rely on colour alone?”, “Which state changed first?”, “What evidence tests that prediction?”, and “Can the case exposing using only a subtle red tint that some users cannot perceive be made smaller?” The learner, not the parent, should supply the technical explanation.

Practice with an explained answer

Question. Build a tiny design decision with :user-invalid is compared with :invalid, classes, aria-invalid and JavaScript validation. Include one ordinary case, one boundary and one deliberate failure caused by using only a subtle red tint that some users cannot perceive. Predict each result before using a tool, then report the first point where observation differs from prediction.

Answer guide. A strong response starts with the rule: Accessible error treatment should combine colour with text, shape, iconography or another cue and maintain readable contrast. It shows a trace, not only a final value. The ordinary case should demonstrate “The stronger boundary and explicit message provide cues beyond hue.” The boundary must exercise the same mechanism at an edge, and the deliberate failure must be repaired with: State the contract for Do not rely on colour alone, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. Other data choices are valid when the evidence supports the same causal chain.

Decision and transfer

For Do not rely on colour alone, separate the documented CSS :user-invalid mechanism from the project policy. State exactly what the technical contract guarantees, then state the project choice about validation, ordering, ownership, performance or recovery. Test whether the same distinction survives one transfer case, and keep stateful experiments disposable and backed up.

Previous chapter . Contents . Next chapter

CHAPTER 12 OF 20 . Handle boundaries

12. A visible message still needs semantics

Back to contents

Generated or shown error text should be programmatically associated with the input, commonly through aria-describedby, and kept accurate. Treat that sentence as a testable model. A secure learner can point to the relevant input, name the operation, describe the resulting state and identify one observation that would prove the model incomplete.

The high-value mistake in this chapter is displaying text nearby with no relationship available to assistive technology. It matters because the output may look reasonable while the ownership, ordering, identity or safety rule is wrong. State the contract for A visible message still needs semantics, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence.

For the A visible message still needs semantics chapter on CSS :user-invalid, use a two-column trace during a short Punggol home session. On the left, write the predicted state for this exact mechanism before the tool runs. On the right, record the observation that bears on displaying text nearby with no relationship available to assistive technology. Explain the earliest difference with one causal sentence, then repeat only the smallest changed case.

Core worked example

<input id="age" aria-describedby="age-error" min="12" type="number">
<p id="age-error">Enter 12 or more.</p>

Explained result. The control identifies the message, while the selector can decide when the message becomes visible. Check the boundary as well as the happy path: ask what happens with an empty input, a duplicate or tied value, an unsupported type, a missing path, a NULL, or a second reference to the same object. Only the relevant boundary should be kept; the list is a prompt for judgment, not a demand to force every case into every example.

Four purposeful transfer cases

Case 1: test laboratory. Contrast the rule using invalid, user-invalid, focus, blur, submit and reset paths are compared. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.

Reasoned route. Begin with “Generated or shown error text should be programmatically associated with the input, commonly through aria-describedby, and kept accurate.” Apply this procedure: State the contract for A visible message still needs semantics, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: The control identifies the message, while the selector can decide when the message becomes visible. For the test laboratory, add one near-miss that exposes displaying text nearby with no relationship available to assistive technology. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.

Case 2: design decision. Stress-test the rule using :user-invalid is compared with :invalid, classes, aria-invalid and JavaScript validation. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.

Reasoned route. Begin with “Generated or shown error text should be programmatically associated with the input, commonly through aria-describedby, and kept accurate.” Apply this procedure: State the contract for A visible message still needs semantics, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: The control identifies the message, while the selector can decide when the message becomes visible. For the design decision, add one near-miss that exposes displaying text nearby with no relationship available to assistive technology. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.

Case 3: homework upload. Explain the rule using a required file description shows feedback after an attempted submission. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.

Reasoned route. Begin with “Generated or shown error text should be programmatically associated with the input, commonly through aria-describedby, and kept accurate.” Apply this procedure: State the contract for A visible message still needs semantics, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: The control identifies the message, while the selector can decide when the message becomes visible. For the homework upload, add one near-miss that exposes displaying text nearby with no relationship available to assistive technology. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.

Case 4: reading club form. Transfer the rule using an email field becomes user-invalid only after meaningful interaction. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.

Reasoned route. Begin with “Generated or shown error text should be programmatically associated with the input, commonly through aria-describedby, and kept accurate.” Apply this procedure: State the contract for A visible message still needs semantics, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: The control identifies the message, while the selector can decide when the message becomes visible. For the reading club form, add one near-miss that exposes displaying text nearby with no relationship available to assistive technology. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.

Diagnostic route

  • Model check: ask the learner to draw or list the exact rows, fields, references, paths or states involved.
  • Boundary check: create the smallest input that triggers displaying text nearby with no relationship available to assistive technology.
  • Evidence check: separate a printed value from identity, ordering, ownership, type or repository state.
  • Repair check: use the reversible procedure “State the contract for A visible message still needs semantics, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence.” and record the first changed observation.
  • Transfer check: repeat the rule in a second context and identify what remains invariant.

A parent does not need to know the final CSS :user-invalid syntax. For this chapter, useful prompts are: “What did you expect from A visible message still needs semantics?”, “Which state changed first?”, “What evidence tests that prediction?”, and “Can the case exposing displaying text nearby with no relationship available to assistive technology be made smaller?” The learner, not the parent, should supply the technical explanation.

Practice with an explained answer

Question. Build a tiny homework upload with a required file description shows feedback after an attempted submission. Include one ordinary case, one boundary and one deliberate failure caused by displaying text nearby with no relationship available to assistive technology. Predict each result before using a tool, then report the first point where observation differs from prediction.

Answer guide. A strong response starts with the rule: Generated or shown error text should be programmatically associated with the input, commonly through aria-describedby, and kept accurate. It shows a trace, not only a final value. The ordinary case should demonstrate “The control identifies the message, while the selector can decide when the message becomes visible.” The boundary must exercise the same mechanism at an edge, and the deliberate failure must be repaired with: State the contract for A visible message still needs semantics, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. Other data choices are valid when the evidence supports the same causal chain.

Decision and transfer

For A visible message still needs semantics, separate the documented CSS :user-invalid mechanism from the project policy. State exactly what the technical contract guarantees, then state the project choice about validation, ordering, ownership, performance or recovery. Test whether the same distinction survives one transfer case, and keep stateful experiments disposable and backed up.

Previous chapter . Contents . Next chapter

CHAPTER 13 OF 20 . Debug and verify

13. aria-invalid is not the same selector

Back to contents

:user-invalid follows native validity and interaction state; aria-invalid communicates an accessibility state but does not itself make the CSS pseudo-class match. Treat that sentence as a testable model. A secure learner can point to the relevant input, name the operation, describe the resulting state and identify one observation that would prove the model incomplete.

The high-value mistake in this chapter is setting aria-invalid=true and expecting :user-invalid to activate automatically. It matters because the output may look reasonable while the ownership, ordering, identity or safety rule is wrong. State the contract for aria-invalid is not the same selector, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence.

For the aria-invalid is not the same selector chapter on CSS :user-invalid, use a two-column trace during a short Punggol home session. On the left, write the predicted state for this exact mechanism before the tool runs. On the right, record the observation that bears on setting aria-invalid=true and expecting :user-invalid to activate automatically. Explain the earliest difference with one causal sentence, then repeat only the smallest changed case.

Core worked example

[aria-invalid="true"]{border-color:#b3261e}
input:user-invalid{border-color:#b3261e}

Explained result. The two selectors can share styling, but their state sources and update responsibilities remain distinct. Check the boundary as well as the happy path: ask what happens with an empty input, a duplicate or tied value, an unsupported type, a missing path, a NULL, or a second reference to the same object. Only the relevant boundary should be kept; the list is a prompt for judgment, not a demand to force every case into every example.

Four purposeful transfer cases

Case 1: homework upload. Stress-test the rule using a required file description shows feedback after an attempted submission. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.

Reasoned route. Begin with “:user-invalid follows native validity and interaction state; aria-invalid communicates an accessibility state but does not itself make the CSS pseudo-class match.” Apply this procedure: State the contract for aria-invalid is not the same selector, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: The two selectors can share styling, but their state sources and update responsibilities remain distinct. For the homework upload, add one near-miss that exposes setting aria-invalid=true and expecting :user-invalid to activate automatically. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.

Case 2: reading club form. Explain the rule using an email field becomes user-invalid only after meaningful interaction. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.

Reasoned route. Begin with “:user-invalid follows native validity and interaction state; aria-invalid communicates an accessibility state but does not itself make the CSS pseudo-class match.” Apply this procedure: State the contract for aria-invalid is not the same selector, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: The two selectors can share styling, but their state sources and update responsibilities remain distinct. For the reading club form, add one near-miss that exposes setting aria-invalid=true and expecting :user-invalid to activate automatically. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.

Case 3: science signup. Transfer the rule using a number outside its min–max range receives a clear error state. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.

Reasoned route. Begin with “:user-invalid follows native validity and interaction state; aria-invalid communicates an accessibility state but does not itself make the CSS pseudo-class match.” Apply this procedure: State the contract for aria-invalid is not the same selector, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: The two selectors can share styling, but their state sources and update responsibilities remain distinct. For the science signup, add one near-miss that exposes setting aria-invalid=true and expecting :user-invalid to activate automatically. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.

Case 4: CCA registration. Predict the rule using a required selection and consent checkbox are tested by keyboard. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.

Reasoned route. Begin with “:user-invalid follows native validity and interaction state; aria-invalid communicates an accessibility state but does not itself make the CSS pseudo-class match.” Apply this procedure: State the contract for aria-invalid is not the same selector, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: The two selectors can share styling, but their state sources and update responsibilities remain distinct. For the CCA registration, add one near-miss that exposes setting aria-invalid=true and expecting :user-invalid to activate automatically. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.

Diagnostic route

  • Model check: ask the learner to draw or list the exact rows, fields, references, paths or states involved.
  • Boundary check: create the smallest input that triggers setting aria-invalid=true and expecting :user-invalid to activate automatically.
  • Evidence check: separate a printed value from identity, ordering, ownership, type or repository state.
  • Repair check: use the reversible procedure “State the contract for aria-invalid is not the same selector, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence.” and record the first changed observation.
  • Transfer check: repeat the rule in a second context and identify what remains invariant.

A parent does not need to know the final CSS :user-invalid syntax. For this chapter, useful prompts are: “What did you expect from aria-invalid is not the same selector?”, “Which state changed first?”, “What evidence tests that prediction?”, and “Can the case exposing setting aria-invalid=true and expecting :user-invalid to activate automatically be made smaller?” The learner, not the parent, should supply the technical explanation.

Practice with an explained answer

Question. Build a tiny reading club form with an email field becomes user-invalid only after meaningful interaction. Include one ordinary case, one boundary and one deliberate failure caused by setting aria-invalid=true and expecting :user-invalid to activate automatically. Predict each result before using a tool, then report the first point where observation differs from prediction.

Answer guide. A strong response starts with the rule: :user-invalid follows native validity and interaction state; aria-invalid communicates an accessibility state but does not itself make the CSS pseudo-class match. It shows a trace, not only a final value. The ordinary case should demonstrate “The two selectors can share styling, but their state sources and update responsibilities remain distinct.” The boundary must exercise the same mechanism at an edge, and the deliberate failure must be repaired with: State the contract for aria-invalid is not the same selector, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. Other data choices are valid when the evidence supports the same causal chain.

Decision and transfer

For aria-invalid is not the same selector, separate the documented CSS :user-invalid mechanism from the project policy. State exactly what the technical contract guarantees, then state the project choice about validation, ordering, ownership, performance or recovery. Test whether the same distinction survives one transfer case, and keep stateful experiments disposable and backed up.

Previous chapter . Contents . Next chapter

CHAPTER 14 OF 20 . Debug and verify

14. Focus styling must remain visible

Back to contents

Error styling should not erase a clear :focus-visible indicator for keyboard users. Treat that sentence as a testable model. A secure learner can point to the relevant input, name the operation, describe the resulting state and identify one observation that would prove the model incomplete.

The high-value mistake in this chapter is using outline:none in the error rule and losing keyboard location. It matters because the output may look reasonable while the ownership, ordering, identity or safety rule is wrong. State the contract for Focus styling must remain visible, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence.

For the Focus styling must remain visible chapter on CSS :user-invalid, use a two-column trace during a short Punggol home session. On the left, write the predicted state for this exact mechanism before the tool runs. On the right, record the observation that bears on using outline:none in the error rule and losing keyboard location. Explain the earliest difference with one causal sentence, then repeat only the smallest changed case.

Core worked example

input:user-invalid{border-color:#b3261e}
input:focus-visible{outline:3px solid #145da0;outline-offset:2px}

Explained result. The control can show both error and keyboard focus without one hiding the other. Check the boundary as well as the happy path: ask what happens with an empty input, a duplicate or tied value, an unsupported type, a missing path, a NULL, or a second reference to the same object. Only the relevant boundary should be kept; the list is a prompt for judgment, not a demand to force every case into every example.

Four purposeful transfer cases

Case 1: science signup. Explain the rule using a number outside its min–max range receives a clear error state. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.

Reasoned route. Begin with “Error styling should not erase a clear :focus-visible indicator for keyboard users.” Apply this procedure: State the contract for Focus styling must remain visible, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: The control can show both error and keyboard focus without one hiding the other. For the science signup, add one near-miss that exposes using outline:none in the error rule and losing keyboard location. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.

Case 2: CCA registration. Transfer the rule using a required selection and consent checkbox are tested by keyboard. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.

Reasoned route. Begin with “Error styling should not erase a clear :focus-visible indicator for keyboard users.” Apply this procedure: State the contract for Focus styling must remain visible, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: The control can show both error and keyboard focus without one hiding the other. For the CCA registration, add one near-miss that exposes using outline:none in the error rule and losing keyboard location. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.

Case 3: family contact form. Predict the rule using a telephone pattern uses text, border and message cues together. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.

Reasoned route. Begin with “Error styling should not erase a clear :focus-visible indicator for keyboard users.” Apply this procedure: State the contract for Focus styling must remain visible, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: The control can show both error and keyboard focus without one hiding the other. For the family contact form, add one near-miss that exposes using outline:none in the error rule and losing keyboard location. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.

Case 4: library reservation. Contrast the rule using a reset clears user-interaction state and returns the form to neutral. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.

Reasoned route. Begin with “Error styling should not erase a clear :focus-visible indicator for keyboard users.” Apply this procedure: State the contract for Focus styling must remain visible, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: The control can show both error and keyboard focus without one hiding the other. For the library reservation, add one near-miss that exposes using outline:none in the error rule and losing keyboard location. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.

Diagnostic route

  • Model check: ask the learner to draw or list the exact rows, fields, references, paths or states involved.
  • Boundary check: create the smallest input that triggers using outline:none in the error rule and losing keyboard location.
  • Evidence check: separate a printed value from identity, ordering, ownership, type or repository state.
  • Repair check: use the reversible procedure “State the contract for Focus styling must remain visible, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence.” and record the first changed observation.
  • Transfer check: repeat the rule in a second context and identify what remains invariant.

A parent does not need to know the final CSS :user-invalid syntax. For this chapter, useful prompts are: “What did you expect from Focus styling must remain visible?”, “Which state changed first?”, “What evidence tests that prediction?”, and “Can the case exposing using outline:none in the error rule and losing keyboard location be made smaller?” The learner, not the parent, should supply the technical explanation.

Practice with an explained answer

Question. Build a tiny science signup with a number outside its min–max range receives a clear error state. Include one ordinary case, one boundary and one deliberate failure caused by using outline:none in the error rule and losing keyboard location. Predict each result before using a tool, then report the first point where observation differs from prediction.

Answer guide. A strong response starts with the rule: Error styling should not erase a clear :focus-visible indicator for keyboard users. It shows a trace, not only a final value. The ordinary case should demonstrate “The control can show both error and keyboard focus without one hiding the other.” The boundary must exercise the same mechanism at an edge, and the deliberate failure must be repaired with: State the contract for Focus styling must remain visible, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. Other data choices are valid when the evidence supports the same causal chain.

Decision and transfer

For Focus styling must remain visible, separate the documented CSS :user-invalid mechanism from the project policy. State exactly what the technical contract guarantees, then state the project choice about validation, ordering, ownership, performance or recovery. Test whether the same distinction survives one transfer case, and keep stateful experiments disposable and backed up.

Previous chapter . Contents . Next chapter

CHAPTER 15 OF 20 . Debug and verify

15. Specificity follows ordinary pseudo-class rules

Back to contents

:user-invalid contributes pseudo-class specificity, so source order and surrounding selectors determine which declaration wins. Treat that sentence as a testable model. A secure learner can point to the relevant input, name the operation, describe the resulting state and identify one observation that would prove the model incomplete.

The high-value mistake in this chapter is adding repeated selectors or !important without calculating the competing rules. It matters because the output may look reasonable while the ownership, ordering, identity or safety rule is wrong. State the contract for Specificity follows ordinary pseudo-class rules, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence.

For the Specificity follows ordinary pseudo-class rules chapter on CSS :user-invalid, use a two-column trace during a short Punggol home session. On the left, write the predicted state for this exact mechanism before the tool runs. On the right, record the observation that bears on adding repeated selectors or !important without calculating the competing rules. Explain the earliest difference with one causal sentence, then repeat only the smallest changed case.

Core worked example

.field:user-invalid{border-color:#b3261e}
.checkout .field{border-color:#777}

Explained result. The class plus pseudo-class rule is more specific than a single class pair only when the full specificity calculation supports it; inspect both selectors and order. Check the boundary as well as the happy path: ask what happens with an empty input, a duplicate or tied value, an unsupported type, a missing path, a NULL, or a second reference to the same object. Only the relevant boundary should be kept; the list is a prompt for judgment, not a demand to force every case into every example.

Four purposeful transfer cases

Case 1: family contact form. Transfer the rule using a telephone pattern uses text, border and message cues together. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.

Reasoned route. Begin with “:user-invalid contributes pseudo-class specificity, so source order and surrounding selectors determine which declaration wins.” Apply this procedure: State the contract for Specificity follows ordinary pseudo-class rules, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: The class plus pseudo-class rule is more specific than a single class pair only when the full specificity calculation supports it; inspect both selectors and order. For the family contact form, add one near-miss that exposes adding repeated selectors or !important without calculating the competing rules. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.

Case 2: library reservation. Predict the rule using a reset clears user-interaction state and returns the form to neutral. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.

Reasoned route. Begin with “:user-invalid contributes pseudo-class specificity, so source order and surrounding selectors determine which declaration wins.” Apply this procedure: State the contract for Specificity follows ordinary pseudo-class rules, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: The class plus pseudo-class rule is more specific than a single class pair only when the full specificity calculation supports it; inspect both selectors and order. For the library reservation, add one near-miss that exposes adding repeated selectors or !important without calculating the competing rules. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.

Case 3: test laboratory. Contrast the rule using invalid, user-invalid, focus, blur, submit and reset paths are compared. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.

Reasoned route. Begin with “:user-invalid contributes pseudo-class specificity, so source order and surrounding selectors determine which declaration wins.” Apply this procedure: State the contract for Specificity follows ordinary pseudo-class rules, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: The class plus pseudo-class rule is more specific than a single class pair only when the full specificity calculation supports it; inspect both selectors and order. For the test laboratory, add one near-miss that exposes adding repeated selectors or !important without calculating the competing rules. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.

Case 4: design decision. Stress-test the rule using :user-invalid is compared with :invalid, classes, aria-invalid and JavaScript validation. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.

Reasoned route. Begin with “:user-invalid contributes pseudo-class specificity, so source order and surrounding selectors determine which declaration wins.” Apply this procedure: State the contract for Specificity follows ordinary pseudo-class rules, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: The class plus pseudo-class rule is more specific than a single class pair only when the full specificity calculation supports it; inspect both selectors and order. For the design decision, add one near-miss that exposes adding repeated selectors or !important without calculating the competing rules. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.

Diagnostic route

  • Model check: ask the learner to draw or list the exact rows, fields, references, paths or states involved.
  • Boundary check: create the smallest input that triggers adding repeated selectors or !important without calculating the competing rules.
  • Evidence check: separate a printed value from identity, ordering, ownership, type or repository state.
  • Repair check: use the reversible procedure “State the contract for Specificity follows ordinary pseudo-class rules, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence.” and record the first changed observation.
  • Transfer check: repeat the rule in a second context and identify what remains invariant.

A parent does not need to know the final CSS :user-invalid syntax. For this chapter, useful prompts are: “What did you expect from Specificity follows ordinary pseudo-class rules?”, “Which state changed first?”, “What evidence tests that prediction?”, and “Can the case exposing adding repeated selectors or !important without calculating the competing rules be made smaller?” The learner, not the parent, should supply the technical explanation.

Practice with an explained answer

Question. Build a tiny CCA registration with a required selection and consent checkbox are tested by keyboard. Include one ordinary case, one boundary and one deliberate failure caused by adding repeated selectors or !important without calculating the competing rules. Predict each result before using a tool, then report the first point where observation differs from prediction.

Answer guide. A strong response starts with the rule: :user-invalid contributes pseudo-class specificity, so source order and surrounding selectors determine which declaration wins. It shows a trace, not only a final value. The ordinary case should demonstrate “The class plus pseudo-class rule is more specific than a single class pair only when the full specificity calculation supports it; inspect both selectors and order.” The boundary must exercise the same mechanism at an edge, and the deliberate failure must be repaired with: State the contract for Specificity follows ordinary pseudo-class rules, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. Other data choices are valid when the evidence supports the same causal chain.

Decision and transfer

For Specificity follows ordinary pseudo-class rules, separate the documented CSS :user-invalid mechanism from the project policy. State exactly what the technical contract guarantees, then state the project choice about validation, ordering, ownership, performance or recovery. Test whether the same distinction survives one transfer case, and keep stateful experiments disposable and backed up.

Previous chapter . Contents . Next chapter

CHAPTER 16 OF 20 . Debug and verify

16. Grouping with is can share state styling

Back to contents

:is(:user-invalid,[aria-invalid=”true”]) can apply a common visual treatment while preserving distinct state management. Treat that sentence as a testable model. A secure learner can point to the relevant input, name the operation, describe the resulting state and identify one observation that would prove the model incomplete.

The high-value mistake in this chapter is grouping states and then assuming they become semantically interchangeable. It matters because the output may look reasonable while the ownership, ordering, identity or safety rule is wrong. State the contract for Grouping with is can share state styling, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence.

For the Grouping with is can share state styling chapter on CSS :user-invalid, use a two-column trace during a short Punggol home session. On the left, write the predicted state for this exact mechanism before the tool runs. On the right, record the observation that bears on grouping states and then assuming they become semantically interchangeable. Explain the earliest difference with one causal sentence, then repeat only the smallest changed case.

Core worked example

.field:is(:user-invalid,[aria-invalid="true"]){border-inline-start:4px solid #b3261e}

Explained result. Either state receives the treatment, but native validity and application-managed aria state still require separate tests. Check the boundary as well as the happy path: ask what happens with an empty input, a duplicate or tied value, an unsupported type, a missing path, a NULL, or a second reference to the same object. Only the relevant boundary should be kept; the list is a prompt for judgment, not a demand to force every case into every example.

Four purposeful transfer cases

Case 1: test laboratory. Predict the rule using invalid, user-invalid, focus, blur, submit and reset paths are compared. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.

Reasoned route. Begin with “:is(:user-invalid,[aria-invalid=”true”]) can apply a common visual treatment while preserving distinct state management.” Apply this procedure: State the contract for Grouping with is can share state styling, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: Either state receives the treatment, but native validity and application-managed aria state still require separate tests. For the test laboratory, add one near-miss that exposes grouping states and then assuming they become semantically interchangeable. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.

Case 2: design decision. Contrast the rule using :user-invalid is compared with :invalid, classes, aria-invalid and JavaScript validation. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.

Reasoned route. Begin with “:is(:user-invalid,[aria-invalid=”true”]) can apply a common visual treatment while preserving distinct state management.” Apply this procedure: State the contract for Grouping with is can share state styling, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: Either state receives the treatment, but native validity and application-managed aria state still require separate tests. For the design decision, add one near-miss that exposes grouping states and then assuming they become semantically interchangeable. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.

Case 3: homework upload. Stress-test the rule using a required file description shows feedback after an attempted submission. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.

Reasoned route. Begin with “:is(:user-invalid,[aria-invalid=”true”]) can apply a common visual treatment while preserving distinct state management.” Apply this procedure: State the contract for Grouping with is can share state styling, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: Either state receives the treatment, but native validity and application-managed aria state still require separate tests. For the homework upload, add one near-miss that exposes grouping states and then assuming they become semantically interchangeable. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.

Case 4: reading club form. Explain the rule using an email field becomes user-invalid only after meaningful interaction. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.

Reasoned route. Begin with “:is(:user-invalid,[aria-invalid=”true”]) can apply a common visual treatment while preserving distinct state management.” Apply this procedure: State the contract for Grouping with is can share state styling, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: Either state receives the treatment, but native validity and application-managed aria state still require separate tests. For the reading club form, add one near-miss that exposes grouping states and then assuming they become semantically interchangeable. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.

Diagnostic route

  • Model check: ask the learner to draw or list the exact rows, fields, references, paths or states involved.
  • Boundary check: create the smallest input that triggers grouping states and then assuming they become semantically interchangeable.
  • Evidence check: separate a printed value from identity, ordering, ownership, type or repository state.
  • Repair check: use the reversible procedure “State the contract for Grouping with is can share state styling, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence.” and record the first changed observation.
  • Transfer check: repeat the rule in a second context and identify what remains invariant.

A parent does not need to know the final CSS :user-invalid syntax. For this chapter, useful prompts are: “What did you expect from Grouping with is can share state styling?”, “Which state changed first?”, “What evidence tests that prediction?”, and “Can the case exposing grouping states and then assuming they become semantically interchangeable be made smaller?” The learner, not the parent, should supply the technical explanation.

Practice with an explained answer

Question. Build a tiny family contact form with a telephone pattern uses text, border and message cues together. Include one ordinary case, one boundary and one deliberate failure caused by grouping states and then assuming they become semantically interchangeable. Predict each result before using a tool, then report the first point where observation differs from prediction.

Answer guide. A strong response starts with the rule: :is(:user-invalid,[aria-invalid=”true”]) can apply a common visual treatment while preserving distinct state management. It shows a trace, not only a final value. The ordinary case should demonstrate “Either state receives the treatment, but native validity and application-managed aria state still require separate tests.” The boundary must exercise the same mechanism at an edge, and the deliberate failure must be repaired with: State the contract for Grouping with is can share state styling, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. Other data choices are valid when the evidence supports the same causal chain.

Decision and transfer

For Grouping with is can share state styling, separate the documented CSS :user-invalid mechanism from the project policy. State exactly what the technical contract guarantees, then state the project choice about validation, ordering, ownership, performance or recovery. Test whether the same distinction survives one transfer case, and keep stateful experiments disposable and backed up.

Previous chapter . Contents . Next chapter

CHAPTER 17 OF 20 . Transfer with judgment

17. A support query can protect enhancement

Back to contents

@supports selector(:user-invalid) can gate the interaction-aware rule while a simpler baseline remains available. Treat that sentence as a testable model. A secure learner can point to the relevant input, name the operation, describe the resulting state and identify one observation that would prove the model incomplete.

The high-value mistake in this chapter is hiding all error treatment in a browser that cannot parse the selector. It matters because the output may look reasonable while the ownership, ordering, identity or safety rule is wrong. State the contract for A support query can protect enhancement, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence.

For the A support query can protect enhancement chapter on CSS :user-invalid, use a two-column trace during a short Punggol home session. On the left, write the predicted state for this exact mechanism before the tool runs. On the right, record the observation that bears on hiding all error treatment in a browser that cannot parse the selector. Explain the earliest difference with one causal sentence, then repeat only the smallest changed case.

Core worked example

.field:invalid{border-color:#8b1e1e}
@supports selector(:user-invalid){.field:invalid{border-color:#777}.field:user-invalid{border-color:#8b1e1e}}

Explained result. The baseline exposes invalidity; supporting browsers replace it with the delayed user-interaction treatment. Check the boundary as well as the happy path: ask what happens with an empty input, a duplicate or tied value, an unsupported type, a missing path, a NULL, or a second reference to the same object. Only the relevant boundary should be kept; the list is a prompt for judgment, not a demand to force every case into every example.

Four purposeful transfer cases

Case 1: homework upload. Contrast the rule using a required file description shows feedback after an attempted submission. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.

Reasoned route. Begin with “@supports selector(:user-invalid) can gate the interaction-aware rule while a simpler baseline remains available.” Apply this procedure: State the contract for A support query can protect enhancement, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: The baseline exposes invalidity; supporting browsers replace it with the delayed user-interaction treatment. For the homework upload, add one near-miss that exposes hiding all error treatment in a browser that cannot parse the selector. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.

Case 2: reading club form. Stress-test the rule using an email field becomes user-invalid only after meaningful interaction. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.

Reasoned route. Begin with “@supports selector(:user-invalid) can gate the interaction-aware rule while a simpler baseline remains available.” Apply this procedure: State the contract for A support query can protect enhancement, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: The baseline exposes invalidity; supporting browsers replace it with the delayed user-interaction treatment. For the reading club form, add one near-miss that exposes hiding all error treatment in a browser that cannot parse the selector. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.

Case 3: science signup. Explain the rule using a number outside its min–max range receives a clear error state. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.

Reasoned route. Begin with “@supports selector(:user-invalid) can gate the interaction-aware rule while a simpler baseline remains available.” Apply this procedure: State the contract for A support query can protect enhancement, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: The baseline exposes invalidity; supporting browsers replace it with the delayed user-interaction treatment. For the science signup, add one near-miss that exposes hiding all error treatment in a browser that cannot parse the selector. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.

Case 4: CCA registration. Transfer the rule using a required selection and consent checkbox are tested by keyboard. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.

Reasoned route. Begin with “@supports selector(:user-invalid) can gate the interaction-aware rule while a simpler baseline remains available.” Apply this procedure: State the contract for A support query can protect enhancement, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: The baseline exposes invalidity; supporting browsers replace it with the delayed user-interaction treatment. For the CCA registration, add one near-miss that exposes hiding all error treatment in a browser that cannot parse the selector. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.

Diagnostic route

  • Model check: ask the learner to draw or list the exact rows, fields, references, paths or states involved.
  • Boundary check: create the smallest input that triggers hiding all error treatment in a browser that cannot parse the selector.
  • Evidence check: separate a printed value from identity, ordering, ownership, type or repository state.
  • Repair check: use the reversible procedure “State the contract for A support query can protect enhancement, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence.” and record the first changed observation.
  • Transfer check: repeat the rule in a second context and identify what remains invariant.

A parent does not need to know the final CSS :user-invalid syntax. For this chapter, useful prompts are: “What did you expect from A support query can protect enhancement?”, “Which state changed first?”, “What evidence tests that prediction?”, and “Can the case exposing hiding all error treatment in a browser that cannot parse the selector be made smaller?” The learner, not the parent, should supply the technical explanation.

Practice with an explained answer

Question. Build a tiny library reservation with a reset clears user-interaction state and returns the form to neutral. Include one ordinary case, one boundary and one deliberate failure caused by hiding all error treatment in a browser that cannot parse the selector. Predict each result before using a tool, then report the first point where observation differs from prediction.

Answer guide. A strong response starts with the rule: @supports selector(:user-invalid) can gate the interaction-aware rule while a simpler baseline remains available. It shows a trace, not only a final value. The ordinary case should demonstrate “The baseline exposes invalidity; supporting browsers replace it with the delayed user-interaction treatment.” The boundary must exercise the same mechanism at an edge, and the deliberate failure must be repaired with: State the contract for A support query can protect enhancement, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. Other data choices are valid when the evidence supports the same causal chain.

Decision and transfer

For A support query can protect enhancement, separate the documented CSS :user-invalid mechanism from the project policy. State exactly what the technical contract guarantees, then state the project choice about validation, ordering, ownership, performance or recovery. Test whether the same distinction survives one transfer case, and keep stateful experiments disposable and backed up.

Previous chapter . Contents . Next chapter

CHAPTER 18 OF 20 . Transfer with judgment

18. Reset returns the form toward neutral interaction state

Back to contents

Resetting the form restores default values and clears the submission-driven user-interaction state under the HTML behaviour. Treat that sentence as a testable model. A secure learner can point to the relevant input, name the operation, describe the resulting state and identify one observation that would prove the model incomplete.

The high-value mistake in this chapter is leaving stale custom error messages or application classes after a reset. It matters because the output may look reasonable while the ownership, ordering, identity or safety rule is wrong. State the contract for Reset returns the form toward neutral interaction state, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence.

For the Reset returns the form toward neutral interaction state chapter on CSS :user-invalid, use a two-column trace during a short Punggol home session. On the left, write the predicted state for this exact mechanism before the tool runs. On the right, record the observation that bears on leaving stale custom error messages or application classes after a reset. Explain the earliest difference with one causal sentence, then repeat only the smallest changed case.

Core worked example

form.reset();
input.setCustomValidity('');

Explained result. Native reset and explicit custom-state cleanup return the test case to a predictable baseline. Check the boundary as well as the happy path: ask what happens with an empty input, a duplicate or tied value, an unsupported type, a missing path, a NULL, or a second reference to the same object. Only the relevant boundary should be kept; the list is a prompt for judgment, not a demand to force every case into every example.

Four purposeful transfer cases

Case 1: science signup. Stress-test the rule using a number outside its min–max range receives a clear error state. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.

Reasoned route. Begin with “Resetting the form restores default values and clears the submission-driven user-interaction state under the HTML behaviour.” Apply this procedure: State the contract for Reset returns the form toward neutral interaction state, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: Native reset and explicit custom-state cleanup return the test case to a predictable baseline. For the science signup, add one near-miss that exposes leaving stale custom error messages or application classes after a reset. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.

Case 2: CCA registration. Explain the rule using a required selection and consent checkbox are tested by keyboard. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.

Reasoned route. Begin with “Resetting the form restores default values and clears the submission-driven user-interaction state under the HTML behaviour.” Apply this procedure: State the contract for Reset returns the form toward neutral interaction state, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: Native reset and explicit custom-state cleanup return the test case to a predictable baseline. For the CCA registration, add one near-miss that exposes leaving stale custom error messages or application classes after a reset. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.

Case 3: family contact form. Transfer the rule using a telephone pattern uses text, border and message cues together. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.

Reasoned route. Begin with “Resetting the form restores default values and clears the submission-driven user-interaction state under the HTML behaviour.” Apply this procedure: State the contract for Reset returns the form toward neutral interaction state, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: Native reset and explicit custom-state cleanup return the test case to a predictable baseline. For the family contact form, add one near-miss that exposes leaving stale custom error messages or application classes after a reset. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.

Case 4: library reservation. Predict the rule using a reset clears user-interaction state and returns the form to neutral. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.

Reasoned route. Begin with “Resetting the form restores default values and clears the submission-driven user-interaction state under the HTML behaviour.” Apply this procedure: State the contract for Reset returns the form toward neutral interaction state, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: Native reset and explicit custom-state cleanup return the test case to a predictable baseline. For the library reservation, add one near-miss that exposes leaving stale custom error messages or application classes after a reset. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.

Diagnostic route

  • Model check: ask the learner to draw or list the exact rows, fields, references, paths or states involved.
  • Boundary check: create the smallest input that triggers leaving stale custom error messages or application classes after a reset.
  • Evidence check: separate a printed value from identity, ordering, ownership, type or repository state.
  • Repair check: use the reversible procedure “State the contract for Reset returns the form toward neutral interaction state, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence.” and record the first changed observation.
  • Transfer check: repeat the rule in a second context and identify what remains invariant.

A parent does not need to know the final CSS :user-invalid syntax. For this chapter, useful prompts are: “What did you expect from Reset returns the form toward neutral interaction state?”, “Which state changed first?”, “What evidence tests that prediction?”, and “Can the case exposing leaving stale custom error messages or application classes after a reset be made smaller?” The learner, not the parent, should supply the technical explanation.

Practice with an explained answer

Question. Build a tiny test laboratory with invalid, user-invalid, focus, blur, submit and reset paths are compared. Include one ordinary case, one boundary and one deliberate failure caused by leaving stale custom error messages or application classes after a reset. Predict each result before using a tool, then report the first point where observation differs from prediction.

Answer guide. A strong response starts with the rule: Resetting the form restores default values and clears the submission-driven user-interaction state under the HTML behaviour. It shows a trace, not only a final value. The ordinary case should demonstrate “Native reset and explicit custom-state cleanup return the test case to a predictable baseline.” The boundary must exercise the same mechanism at an edge, and the deliberate failure must be repaired with: State the contract for Reset returns the form toward neutral interaction state, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. Other data choices are valid when the evidence supports the same causal chain.

Decision and transfer

For Reset returns the form toward neutral interaction state, separate the documented CSS :user-invalid mechanism from the project policy. State exactly what the technical contract guarantees, then state the project choice about validation, ordering, ownership, performance or recovery. Test whether the same distinction survives one transfer case, and keep stateful experiments disposable and backed up.

Previous chapter . Contents . Next chapter

CHAPTER 19 OF 20 . Transfer with judgment

19. Testing needs an interaction matrix

Back to contents

A reliable test covers untouched load, invalid edit, focus movement, failed submit, correction, keyboard operation and reset in target browsers. Treat that sentence as a testable model. A secure learner can point to the relevant input, name the operation, describe the resulting state and identify one observation that would prove the model incomplete.

The high-value mistake in this chapter is taking a screenshot of one red field as proof that the complete flow works. It matters because the output may look reasonable while the ownership, ordering, identity or safety rule is wrong. State the contract for Testing needs an interaction matrix, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence.

For the Testing needs an interaction matrix chapter on CSS :user-invalid, use a two-column trace during a short Punggol home session. On the left, write the predicted state for this exact mechanism before the tool runs. On the right, record the observation that bears on taking a screenshot of one red field as proof that the complete flow works. Explain the earliest difference with one causal sentence, then repeat only the smallest changed case.

Core worked example

// test: load -> focus -> type invalid -> blur -> submit -> correct -> reset

Explained result. The sequence reveals timing, validity, focus visibility and recovery rather than only final paint. Check the boundary as well as the happy path: ask what happens with an empty input, a duplicate or tied value, an unsupported type, a missing path, a NULL, or a second reference to the same object. Only the relevant boundary should be kept; the list is a prompt for judgment, not a demand to force every case into every example.

Four purposeful transfer cases

Case 1: family contact form. Explain the rule using a telephone pattern uses text, border and message cues together. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.

Reasoned route. Begin with “A reliable test covers untouched load, invalid edit, focus movement, failed submit, correction, keyboard operation and reset in target browsers.” Apply this procedure: State the contract for Testing needs an interaction matrix, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: The sequence reveals timing, validity, focus visibility and recovery rather than only final paint. For the family contact form, add one near-miss that exposes taking a screenshot of one red field as proof that the complete flow works. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.

Case 2: library reservation. Transfer the rule using a reset clears user-interaction state and returns the form to neutral. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.

Reasoned route. Begin with “A reliable test covers untouched load, invalid edit, focus movement, failed submit, correction, keyboard operation and reset in target browsers.” Apply this procedure: State the contract for Testing needs an interaction matrix, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: The sequence reveals timing, validity, focus visibility and recovery rather than only final paint. For the library reservation, add one near-miss that exposes taking a screenshot of one red field as proof that the complete flow works. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.

Case 3: test laboratory. Predict the rule using invalid, user-invalid, focus, blur, submit and reset paths are compared. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.

Reasoned route. Begin with “A reliable test covers untouched load, invalid edit, focus movement, failed submit, correction, keyboard operation and reset in target browsers.” Apply this procedure: State the contract for Testing needs an interaction matrix, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: The sequence reveals timing, validity, focus visibility and recovery rather than only final paint. For the test laboratory, add one near-miss that exposes taking a screenshot of one red field as proof that the complete flow works. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.

Case 4: design decision. Contrast the rule using :user-invalid is compared with :invalid, classes, aria-invalid and JavaScript validation. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.

Reasoned route. Begin with “A reliable test covers untouched load, invalid edit, focus movement, failed submit, correction, keyboard operation and reset in target browsers.” Apply this procedure: State the contract for Testing needs an interaction matrix, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: The sequence reveals timing, validity, focus visibility and recovery rather than only final paint. For the design decision, add one near-miss that exposes taking a screenshot of one red field as proof that the complete flow works. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.

Diagnostic route

  • Model check: ask the learner to draw or list the exact rows, fields, references, paths or states involved.
  • Boundary check: create the smallest input that triggers taking a screenshot of one red field as proof that the complete flow works.
  • Evidence check: separate a printed value from identity, ordering, ownership, type or repository state.
  • Repair check: use the reversible procedure “State the contract for Testing needs an interaction matrix, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence.” and record the first changed observation.
  • Transfer check: repeat the rule in a second context and identify what remains invariant.

A parent does not need to know the final CSS :user-invalid syntax. For this chapter, useful prompts are: “What did you expect from Testing needs an interaction matrix?”, “Which state changed first?”, “What evidence tests that prediction?”, and “Can the case exposing taking a screenshot of one red field as proof that the complete flow works be made smaller?” The learner, not the parent, should supply the technical explanation.

Practice with an explained answer

Question. Build a tiny design decision with :user-invalid is compared with :invalid, classes, aria-invalid and JavaScript validation. Include one ordinary case, one boundary and one deliberate failure caused by taking a screenshot of one red field as proof that the complete flow works. Predict each result before using a tool, then report the first point where observation differs from prediction.

Answer guide. A strong response starts with the rule: A reliable test covers untouched load, invalid edit, focus movement, failed submit, correction, keyboard operation and reset in target browsers. It shows a trace, not only a final value. The ordinary case should demonstrate “The sequence reveals timing, validity, focus visibility and recovery rather than only final paint.” The boundary must exercise the same mechanism at an edge, and the deliberate failure must be repaired with: State the contract for Testing needs an interaction matrix, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. Other data choices are valid when the evidence supports the same causal chain.

Decision and transfer

For Testing needs an interaction matrix, separate the documented CSS :user-invalid mechanism from the project policy. State exactly what the technical contract guarantees, then state the project choice about validation, ordering, ownership, performance or recovery. Test whether the same distinction survives one transfer case, and keep stateful experiments disposable and backed up.

Previous chapter . Contents . Next chapter

CHAPTER 20 OF 20 . Transfer with judgment

20. Choose user-invalid for delayed native error presentation

Back to contents

Use :user-invalid when HTML validity plus user interaction should control feedback; use :invalid for immediate state, aria-invalid or classes for application-managed rules, and JavaScript when timing or messages require explicit control. Treat that sentence as a testable model. A secure learner can point to the relevant input, name the operation, describe the resulting state and identify one observation that would prove the model incomplete.

The high-value mistake in this chapter is adding the selector to every input without deciding who owns validity and messages. It matters because the output may look reasonable while the ownership, ordering, identity or safety rule is wrong. State the contract for Choose user-invalid for delayed native error presentation, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence.

For the Choose user-invalid for delayed native error presentation chapter on CSS :user-invalid, use a two-column trace during a short Punggol home session. On the left, write the predicted state for this exact mechanism before the tool runs. On the right, record the observation that bears on adding the selector to every input without deciding who owns validity and messages. Explain the earliest difference with one causal sentence, then repeat only the smallest changed case.

Core worked example

.field:user-invalid + .error{display:block}

Explained result. The pattern is defensible when native constraints are accurate, the message is associated, focus remains visible and cross-browser interaction tests pass. Check the boundary as well as the happy path: ask what happens with an empty input, a duplicate or tied value, an unsupported type, a missing path, a NULL, or a second reference to the same object. Only the relevant boundary should be kept; the list is a prompt for judgment, not a demand to force every case into every example.

Four purposeful transfer cases

Case 1: test laboratory. Transfer the rule using invalid, user-invalid, focus, blur, submit and reset paths are compared. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.

Reasoned route. Begin with “Use :user-invalid when HTML validity plus user interaction should control feedback; use :invalid for immediate state, aria-invalid or classes for application-managed rules, and JavaScript when timing or messages require explicit control.” Apply this procedure: State the contract for Choose user-invalid for delayed native error presentation, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: The pattern is defensible when native constraints are accurate, the message is associated, focus remains visible and cross-browser interaction tests pass. For the test laboratory, add one near-miss that exposes adding the selector to every input without deciding who owns validity and messages. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.

Case 2: design decision. Predict the rule using :user-invalid is compared with :invalid, classes, aria-invalid and JavaScript validation. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.

Reasoned route. Begin with “Use :user-invalid when HTML validity plus user interaction should control feedback; use :invalid for immediate state, aria-invalid or classes for application-managed rules, and JavaScript when timing or messages require explicit control.” Apply this procedure: State the contract for Choose user-invalid for delayed native error presentation, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: The pattern is defensible when native constraints are accurate, the message is associated, focus remains visible and cross-browser interaction tests pass. For the design decision, add one near-miss that exposes adding the selector to every input without deciding who owns validity and messages. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.

Case 3: homework upload. Contrast the rule using a required file description shows feedback after an attempted submission. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.

Reasoned route. Begin with “Use :user-invalid when HTML validity plus user interaction should control feedback; use :invalid for immediate state, aria-invalid or classes for application-managed rules, and JavaScript when timing or messages require explicit control.” Apply this procedure: State the contract for Choose user-invalid for delayed native error presentation, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: The pattern is defensible when native constraints are accurate, the message is associated, focus remains visible and cross-browser interaction tests pass. For the homework upload, add one near-miss that exposes adding the selector to every input without deciding who owns validity and messages. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.

Case 4: reading club form. Stress-test the rule using an email field becomes user-invalid only after meaningful interaction. State the input grain or object graph, the chapter boundary and the intended output before choosing syntax. Change only one variable, so a wrong prediction has a single plausible cause.

Reasoned route. Begin with “Use :user-invalid when HTML validity plus user interaction should control feedback; use :invalid for immediate state, aria-invalid or classes for application-managed rules, and JavaScript when timing or messages require explicit control.” Apply this procedure: State the contract for Choose user-invalid for delayed native error presentation, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. The expected mechanism is: The pattern is defensible when native constraints are accurate, the message is associated, focus remains visible and cross-browser interaction tests pass. For the reading club form, add one near-miss that exposes adding the selector to every input without deciding who owns validity and messages. The answer is complete only when it says why the near-miss fails and how the corrected model transfers to a different project without relying on the original variable names.

Diagnostic route

  • Model check: ask the learner to draw or list the exact rows, fields, references, paths or states involved.
  • Boundary check: create the smallest input that triggers adding the selector to every input without deciding who owns validity and messages.
  • Evidence check: separate a printed value from identity, ordering, ownership, type or repository state.
  • Repair check: use the reversible procedure “State the contract for Choose user-invalid for delayed native error presentation, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence.” and record the first changed observation.
  • Transfer check: repeat the rule in a second context and identify what remains invariant.

A parent does not need to know the final CSS :user-invalid syntax. For this chapter, useful prompts are: “What did you expect from Choose user-invalid for delayed native error presentation?”, “Which state changed first?”, “What evidence tests that prediction?”, and “Can the case exposing adding the selector to every input without deciding who owns validity and messages be made smaller?” The learner, not the parent, should supply the technical explanation.

Practice with an explained answer

Question. Build a tiny homework upload with a required file description shows feedback after an attempted submission. Include one ordinary case, one boundary and one deliberate failure caused by adding the selector to every input without deciding who owns validity and messages. Predict each result before using a tool, then report the first point where observation differs from prediction.

Answer guide. A strong response starts with the rule: Use :user-invalid when HTML validity plus user interaction should control feedback; use :invalid for immediate state, aria-invalid or classes for application-managed rules, and JavaScript when timing or messages require explicit control. It shows a trace, not only a final value. The ordinary case should demonstrate “The pattern is defensible when native constraints are accurate, the message is associated, focus remains visible and cross-browser interaction tests pass.” The boundary must exercise the same mechanism at an edge, and the deliberate failure must be repaired with: State the contract for Choose user-invalid for delayed native error presentation, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. Other data choices are valid when the evidence supports the same causal chain.

Decision and transfer

For Choose user-invalid for delayed native error presentation, separate the documented CSS :user-invalid mechanism from the project policy. State exactly what the technical contract guarantees, then state the project choice about validation, ordering, ownership, performance or recovery. Test whether the same distinction survives one transfer case, and keep stateful experiments disposable and backed up.

Previous chapter . Contents . Next chapter

Parent guide: choose the next useful step

Start with evidence, not a label such as careless. Ask for one prediction and one trace. If the first transition is wrong, rebuild the model. If the model is sound but syntax fails, practise reference use. If routine cases are correct but boundaries fail, vary ties, defaults, unsupported inputs, ownership or missing paths. If explanations transfer, move to a small project.

Keep a weekly record with four lines: concept, prediction, observed difference and next test. Stop when fatigue replaces reasoning. A smaller case tomorrow is more useful than another hour of copying tonight.

Seek specialist help when cause and effect remain invisible after examples are reduced, when accessibility or data-loss implications are unclear, or when an important repository, database or application state may be at risk. Good support should make the learner’s reasoning more independent.

Capstone practice with explained routes

1. homework upload: model, boundary and recovery

Create a small homework upload using a required file description shows feedback after an attempted submission. Combine “Validity comes from the control contract” with one later chapter. Include an ordinary case, a boundary, a deliberate failure and a recovery. Write the expected state before each operation.

Explained route. Start with: :user-invalid can only match an element that is invalid according to the host language validation rules. Apply: State the contract for Validity comes from the control contract, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. Verify: An empty or malformed required email can become user-invalid after the relevant interaction; CSS itself does not create the constraint. Then add a second chapter whose boundary could change the outcome. A complete solution contains the input model, a trace, observed evidence, a correction and one transfer statement. The exact data may differ; the causal chain must be checkable.

2. reading club form: model, boundary and recovery

Create a small reading club form using an email field becomes user-invalid only after meaningful interaction. Combine “Pre-submission timing may vary” with one later chapter. Include an ordinary case, a boundary, a deliberate failure and a recovery. Write the expected state before each operation.

Explained route. Start with: Before submission, browsers may decide that changing a value and moving focus is significant interaction, but exact timing is not universally fixed by Selectors alone. Apply: State the contract for Pre-submission timing may vary, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. Verify: The rule is portable as a state style, while tests must cover the target browsers interaction sequence. Then add a second chapter whose boundary could change the outcome. A complete solution contains the input model, a trace, observed evidence, a correction and one transfer statement. The exact data may differ; the causal chain must be checkable.

3. science signup: model, boundary and recovery

Create a small science signup using a number outside its min–max range receives a clear error state. Combine “Range constraints are distinct evidence” with one later chapter. Include an ordinary case, a boundary, a deliberate failure and a recovery. Write the expected state before each operation.

Explained route. Start with: Number and date-like controls can be invalid because values fall below min, above max or violate step. Apply: State the contract for Range constraints are distinct evidence, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. Verify: The control is invalid because 11 exceeds max, so the nearby message should explain the actual range. Then add a second chapter whose boundary could change the outcome. A complete solution contains the input model, a trace, observed evidence, a correction and one transfer statement. The exact data may differ; the causal chain must be checkable.

4. CCA registration: model, boundary and recovery

Create a small CCA registration using a required selection and consent checkbox are tested by keyboard. Combine “CSS does not replace validation logic” with one later chapter. Include an ordinary case, a boundary, a deliberate failure and a recovery. Write the expected state before each operation.

Explained route. Start with: :user-invalid styles a state; it does not sanitize data, protect a server or decide business rules. Apply: State the contract for CSS does not replace validation logic, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. Verify: Client-side presentation helps the user, while server-side validation and domain checks remain mandatory. Then add a second chapter whose boundary could change the outcome. A complete solution contains the input model, a trace, observed evidence, a correction and one transfer statement. The exact data may differ; the causal chain must be checkable.

5. family contact form: model, boundary and recovery

Create a small family contact form using a telephone pattern uses text, border and message cues together. Combine “aria-invalid is not the same selector” with one later chapter. Include an ordinary case, a boundary, a deliberate failure and a recovery. Write the expected state before each operation.

Explained route. Start with: :user-invalid follows native validity and interaction state; aria-invalid communicates an accessibility state but does not itself make the CSS pseudo-class match. Apply: State the contract for aria-invalid is not the same selector, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. Verify: The two selectors can share styling, but their state sources and update responsibilities remain distinct. Then add a second chapter whose boundary could change the outcome. A complete solution contains the input model, a trace, observed evidence, a correction and one transfer statement. The exact data may differ; the causal chain must be checkable.

6. library reservation: model, boundary and recovery

Create a small library reservation using a reset clears user-interaction state and returns the form to neutral. Combine “Grouping with is can share state styling” with one later chapter. Include an ordinary case, a boundary, a deliberate failure and a recovery. Write the expected state before each operation.

Explained route. Start with: :is(:user-invalid,[aria-invalid=”true”]) can apply a common visual treatment while preserving distinct state management. Apply: State the contract for Grouping with is can share state styling, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. Verify: Either state receives the treatment, but native validity and application-managed aria state still require separate tests. Then add a second chapter whose boundary could change the outcome. A complete solution contains the input model, a trace, observed evidence, a correction and one transfer statement. The exact data may differ; the causal chain must be checkable.

7. test laboratory: model, boundary and recovery

Create a small test laboratory using invalid, user-invalid, focus, blur, submit and reset paths are compared. Combine “Testing needs an interaction matrix” with one later chapter. Include an ordinary case, a boundary, a deliberate failure and a recovery. Write the expected state before each operation.

Explained route. Start with: A reliable test covers untouched load, invalid edit, focus movement, failed submit, correction, keyboard operation and reset in target browsers. Apply: State the contract for Testing needs an interaction matrix, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. Verify: The sequence reveals timing, validity, focus visibility and recovery rather than only final paint. Then add a second chapter whose boundary could change the outcome. A complete solution contains the input model, a trace, observed evidence, a correction and one transfer statement. The exact data may differ; the causal chain must be checkable.

8. design decision: model, boundary and recovery

Create a small design decision using :user-invalid is compared with :invalid, classes, aria-invalid and JavaScript validation. Combine “User interaction distinguishes it from invalid” with one later chapter. Include an ordinary case, a boundary, a deliberate failure and a recovery. Write the expected state before each operation.

Explained route. Start with: :invalid reflects current constraint validity, while :user-invalid waits for significant user interaction under the platform rules. Apply: State the contract for User interaction distinguishes it from invalid, predict one ordinary case and one boundary, run the smallest disposable test, then explain the earliest difference between prediction and evidence. Verify: An untouched required field can match :invalid before it matches :user-invalid. Then add a second chapter whose boundary could change the outcome. A complete solution contains the input model, a trace, observed evidence, a correction and one transfer statement. The exact data may differ; the causal chain must be checkable.

Frequently asked questions

How long should a practice session be?

Use one complete prediction–observation–explanation cycle while attention remains good. Ten to twenty focused minutes can be enough.

Should every option or function be memorised?

No. Memorise the governing distinctions and practise retrieving the official reference. Understanding means predicting and explaining, not reciting a parameter list.

What if the result is correct but the explanation is weak?

Treat it as partial success. Ask for a trace and change one boundary. A reliable model survives controlled variation.

Is the shortest solution the best?

Not automatically. Prefer the solution whose semantics, failure modes and maintenance cost are easiest to justify for the actual project.

When should official documentation be used?

Use it whenever syntax, supported types, SQL dialect behaviour or Git version details matter. Primary documentation settles the current contract.

How can a parent help without technical expertise?

Ask what was predicted, where the first difference appeared, what evidence matters and which smaller example could isolate it.

How do we test transfer?

Change the context, vocabulary and one boundary. Require the learner to identify the invariant before using a tool.

What should be saved after practice?

Keep the corrected rule, one trace, one boundary case and the next question. Avoid storing pages of unexplained output.

Can these exercises replace backups?

No. Use disposable examples and proper backups. Learning should not endanger schoolwork, repositories or personal data.

What counts as mastery?

The learner can predict, verify, diagnose, recover and justify a choice across more than one context, while knowing when to consult the current reference.

Official and supporting references

Return to contents

Continue from here: Start Here · Tuition · Education · Pathways · Parenting 101 · All Site Routes

eduKate Punggol

Contact

83 Punggol Central, Singapore 828761

edu|Kate Bukit Timah

8 Fourth Avenue, Singapore 268674

By Appointment +65 8823 1234
admin@edukatesg.com

Email Us

When a child finally understands, school becomes less frightening and the future opens wider. Email us for the latest schedules and fees.

← 返回

感谢您的回复。 ✨

了解 eduKate Punggol 的更多信息

立即订阅以继续阅读并访问完整档案。

继续阅读