Building Your Learning Module...
Getting things ready for you!
Find videos you like?
Save to resource drawer for future reference!
Catch syntax errors before they break your site
Ensure CSS follows standards (W3C)
Find deprecated properties
Enforce code style consistency
Improve code quality automatically
Essential for professional development
Check for CSS errors
Missing semicolons, wrong propertiesFollows W3C CSS specifications
Valid CSS properties and valuesBest practices and conventions
Consistent formatting, no duplicatesEnforce style rules
Indentation, naming, orderOfficial validator from the World Wide Web Consortium (W3C). Checks if your CSS follows official CSS specifications.
🌐 Website:
https://jigsaw.w3.org/css-validator//* ✅ VALID CSS - No errors */
.button {
background-color: #3b82f6;
color: white;
padding: 12px 24px;
border: none;
border-radius: 6px;
cursor: pointer;
}
.button:hover {
background-color: #2563eb;
}
/* All properties are valid */
/* All values are correct */
/* Proper syntax throughout *//* ❌ INVALID CSS - Has errors */
.button {
background-color: #3b82f6;
colour: white; /* ❌ Wrong: should be 'color' */
padding: 12px 24px
border: none; /* ❌ Missing semicolon above */
border-radius: 6px;
cursor: pointer;
animation-delay: 0.5ss; /* ❌ Wrong: should be '0.5s' */
}
.button:hover {
background-colour: #2563eb; /* ❌ Wrong: should be 'background-color' */
}
/* W3C Validator will catch ALL these errors! */A modern linter that helps you avoid errors and enforce conventions in your CSS. Catches more issues than W3C validator and can auto-fix many problems!
✓ Catches 170+ errors
Syntax, naming, values, more
✓ Auto-fix support
Fixes many issues automatically
# Install Stylelint
npm install --save-dev stylelint stylelint-config-standard
# Create config file (.stylelintrc.json)
{
"extends": "stylelint-config-standard",
"rules": {
"indentation": 2,
"color-hex-length": "short",
"selector-class-pattern": "^[a-z][a-z0-9-]*$"
}
}# Check all CSS files
npx stylelint "**/*.css"
# Auto-fix issues
npx stylelint "**/*.css" --fix
# Check specific file
npx stylelint styles.cssErrors:
Style Issues:
Stylelint
Integrates Stylelint into VS Code. Shows errors inline as you type.
Extension ID: stylelint.vscode-stylelintPrettier
Auto-formats CSS on save. Keeps code consistent.
Extension ID: esbenp.prettier-vscodeCSS Peek
Jump to CSS definition from HTML. Makes navigation easier.
Extension ID: pranaygp.vscode-css-peekWrong:
colour: blue;backgrund: red;padding-botom: 10px;Correct:
color: blue;background: red;padding-bottom: 10px;Wrong:
.box {
width: 100px
height: 100px;
}Correct:
.box {
width: 100px;
height: 100px;
}Wrong:
width: 100pxs;color: #fff; (should be 6 digits)margin: 10 20; (missing units)Correct:
width: 100px;color: #ffffff;margin: 10px 20px;Wrong:
display: flex; display: -webkit-flex;
Correct:
display: -webkit-flex; display: flex;
Find typos and syntax errors before they cause problems. Much faster than debugging in the browser!
Validators warn about properties that don't work in certain browsers. Avoid surprises!
Enforce consistent formatting and best practices. Makes code easier to read and maintain!
Validators explain why something is wrong. You learn while you code!
Always validate before going live
Use linters to catch errors as you type
Enforce consistent code style
Find issues in old CSS files
--fix flag with Stylelint to fix issues automaticallyW3C Validator: Official standard, free, web-based, catches syntax errors
Stylelint: Modern, powerful, auto-fix, 170+ rules, integrates with editors
CSSLint: Older tool, still useful, focuses on code quality
Prettier: Not a validator, but formats CSS consistently