Topic 41 of 41
Code Editors & Setup
Overview
You can technically write HTML in Notepad or TextEdit, but that's like trying to cut down a tree with a butter knife. Professional developers use Integrated Development Environments (IDEs) or specialized Code Editors.
These tools provide syntax highlighting (coloring your tags so they are easy to read), auto-completion, error checking, and live previews of your website.
Syntax
Visual Studio Code (VS Code) is the industry standard editor. It comes with a magical feature called 'Emmet' built-in. Emmet allows you to type shortcuts that instantly expand into massive blocks of HTML code.
VS Code & Emmet
html
<!-- In VS Code, simply type the exclamation mark '!' and press Tab. -->
! + Tab
<!-- It instantly generates the entire boilerplate: -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
</body>
</html>You can create complex HTML structures in seconds using Emmet abbreviations.
Fast Emmet Shortcuts
html
<!-- Type this and press Tab: -->
ul>li*3
<!-- It generates: -->
<ul>
<li></li>
<li></li>
<li></li>
</ul>
<!-- Type this and press Tab: -->
.card>h2+p
<!-- It generates: -->
<div class="card">
<h2></h2>
<p></p>
</div>Common Pitfalls
- Opening your HTML file by double-clicking it (so the URL says file:///C:/...) is okay for extreme basics, but it breaks many advanced features (like fetching data or using modules). Always use 'Live Server' to run your site on localhost.
Real-World Example
The must-have VS Code Extensions for HTML Developers:
example
html
/*
Highly Recommended Extensions:
1. Live Server (by Ritwick Dey)
- Launches a local development server with live reload.
- Every time you save your HTML file, the browser refreshes instantly!
2. Prettier - Code formatter
- Automatically indents and formats your ugly code
- Makes it perfectly readable every time you save.
3. Auto Rename Tag
- When you change an opening <div> to a <section>,
- it automatically changes the closing tag for you!
*/