HTML & CSS Best Practices
HTML
Some say it’s a forgiving language.
Successful rendering != semantically correct.
Continually Refactor Code
Take time to evaluate and refactor your codes after you write it, looking for ways to
condense it and make it more manageable.
Goal
Be well organized, so that it is easy to read, edit, and maintain
Be modular and flexible, allowing us to reuse code and patterns as necessary
Proper Document Structure
DOCTYPE is an instruction to the web browser about what version of HTML the page is written in.
HTML content/structure/css/images of your page will be loaded first, Your users don't
have to wait for a script to finish downloading before they see something in your page.
Standards-Compliant Markup
ID attribute value should be a unique value.
Class attribute can be used multiple times.
Semantic Elements
Using semantic tags gives you many more hooks for styling your content
Syntax Organized
Avoid Inline CSS
Inline CSS can’t be reused.
Practical Class Values
Class value not relate on function/content.
Class value not relate on function/content.
Use multiple values in class attribute.
CSS
Focus on keeping code lean and well organized
Comments
Keep our styles organized in logical groups.
Provide a comment noting what the following styles pertain to.
Practical Class Name
Class name should be modular
Shorthand Property
Modular Styles
CSS Preprocessor
Better file organization
Nested syntax
Variables
Mixins
Mathematical functions
Operational functions (such as “lighten” and “darken”)
Multiple files to generate only one.
Avoid repetitions
SASS / LESS
SASS
File Organization
Overly Nested Rules
Use Specific Classes When Necessary
Extend Ruleset
Use @extend to help you reuse other ruleset
Resource
Case studies, co-workers, internet
Goal
Be well organized & be modular and flexible.
Fin.

HTML CSS Best Practices