Best Practices
Conventions to Follow
# Filenames
- Keep all your file and folder names lowercase.
- Do NOT use spaces in your file or folder names. Instead use hyphens, underscores, or periods. Whichever you choose, do it consistently.
- Use meaningful names.
- HTML homepages are always called
index.html. This is the default name for every folder.
# HTML
- Use lowercase for your tags and attributes.
- Use double quotes for around all attribute values.
- Use the HTML5 declaration and root tag for every webpage.
<!DOCTYPE html>
<html lang="en"></html>
1
2
2
# CSS
- Use
remunits for font-sizes and media query break points. - Use
chunits for line lengths in paragraphs or form labels. - When creating mastheads and banners that need a height, use
vhvalues. - The Viewpoint units
vw,vh,vmin, andvmaxare good for layout min and max sizes. - CSS classnames should be descriptive and indicate the part of the interface they style. Avoid things like
p1.
# JavaScript
- Add lots of comments. Explain your code to yourself and others.
- Variable names should be meaningful. Avoid abbreviations.
- Variable names made from multiple words should use camelcase.
- Having more lines of code that are easy to read and understand, is better than trying to use shortcuts to save a couple bytes and ending up with code that is hard to read and understand.
# Git
- Use
git commitfrequently. - Commit messages should always be meaningful. Avoid things like
"Updated script". git statuswill help you see how much you have edited since your last commit.- Always start with
git pull.
# Comments
- Add lots of comments to your CSS and JavaScript and Git Commits. The comments help other people when reading your code and help you when you come back to edit your code.