Professional Business Website · Phase 5 · Lesson 1 of 3
Validating Code and Fixing Errors
Run every page through the W3C HTML and CSS validators, understand the most common errors, and fix them without breaking the layout.
What you need
A computer (Windows, macOS or Linux) with Visual Studio Code (free) and a current web browser such as Chrome or Firefox. A smartphone is used for testing. Internet access for the online validators.
In this lesson you will
- Validate HTML and CSS and interpret error messages
- Fix errors in order of importance
Key concepts
validatorerrorwarningunclosed elementduplicate id
The lesson
Validators find mistakes that browsers silently hide: unclosed elements, duplicate ids, invalid attributes, typos in CSS properties. Browsers guess how to display broken code, and different browsers guess differently.
Fix errors before warnings, and fix the first error first; one unclosed element can cause many later errors that disappear once it is fixed.
Re-test the page visually after each fix and commit with a message such as 'Fix unclosed section on services page'.
Step by step
- Validate each HTML page with the W3C Markup Validation Service.
- Validate the stylesheet with the W3C CSS Validation Service.
- Fix errors one by one, re-validating as you go.
- Record the results in a test log.
Practice activity
Validate all pages and the stylesheet, fix every error, and record results in the test log.
Expected result: All pages and the stylesheet pass validation with no errors, and the test log records what was fixed.
Common mistakes
- Ignoring validator errors because the page looks fine in one browser
- Fixing many errors at once and losing track of what changed
Check your understanding
-
Why fix the first validator error first?
Show answer
One error, such as an unclosed element, can cause many later errors.
-
Why validate if the page already looks fine?
Show answer
Browsers hide errors differently; invalid code can break in another browser or for assistive technology.
Further learning
Projects are instructor-guided: an instructor sets milestones, checks your work and gives feedback, online or in person. Self-study of the public lessons does not lead to a certificate. Enrolment and fees follow the Academy's existing policies — contact the Academy.