Conventions
Filenames
Section titled “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. - Put your JavaScript files inside a
jsfolder. - Put your CSS files inside a
cssfolder. - Put your image files inside a
imgfolder. - Put your audio and video files inside a
mediafolder. - Put your local font files inside a
fontsfolder.
- 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>- 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,cqi,vmin, andvmaxare good for layout min and max sizes. - CSS classnames should be descriptive and indicate the part of the interface they style or their purpose on the page. Avoid things like
p1ormydivs.
JavaScript
Section titled “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.
- Start every project by creating a repo on Github. Then locally run
git initandgit remote add origin <repo-address>. - 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
Section titled “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.