Code Style Guidelines (HTML)
Document Structure
1. Start with <!DOCTYPE html>, followed by the <html> tag.
2. Use semantic tags like <header>, <footer>, <section>, <main>, <nav>, etc. when appropriate.
3. Always include <meta charset="UTF-8"> in your <head> tag for proper text rendering.
Indentation
1. Use a 2-space indent for nested elements.
Naming Conventions
1. Use lowercase for tags, attributes, and file names.
2. Separate words in ID and class names by a hyphen.
General Formatting
1. Always close tags. For tags that don’t have a closing pair, like <img>, <br>, etc., close them self, e.g., <img src="image.jpg" alt="Image" />.
2. Use double quotes around attribute values.
3. Avoid inline CSS when possible. Prefer linking to an external stylesheet.
Images
1. Always include alt attributes for accessibility and in case the image fails to load.
2. Use CSS for backgrounds rather than images, when possible.
Comments
1. Use comments to explain the code and keep them updated with the code.
Last updated