Hi!
I know reading the title may make you feel like "what on earth is his problem" π€π but bear with me.
I'm not talking about the regular stuff like meta tags, code validation, modular IE tricks, etc. I'm thinking about the more basic things like what class names to use, should I use divs or ul li for list?! Is there some sort of a convention to follow here?
I waste most of my time thinking about this, I'm not sure if I have a fundamental problem in me OR is this a common issue.
I tend to use different coding styles in each project (worst case in the same project) and that sometimes sucks π
Can you guys share some knowledge on this?
For me the best practice is to use semantic HTML tags.
There are several examples and I don't want to decide, which works the best for you. It will depends on the project.
As mentioned before me, you can use semantic HTML tags.
I always use 1 <nav> tag at the top level which contains all my navigation links at the top of my page. 1 <main> tag that contains all my content which is related to my page and 1 <footer>.
My advise is don't overuse <div>.It will helping you to make better SEO (and user) experience. Look at HTML as a skeleton for your page. I know it could be overwhelming at first.
You can read more about it here:
https://www.w3schools.com/html/html5_semantic_elements.asp
For CSS there are multiple best practices. BEM also mentioned here which could help you to keep all your CSS files DRY. For me, I'm using SCSS 7-1 (sometimes 7-2) patterns, but it is really up to you (and the project), which works the best for you.
BEM is a naming convention for CSS classes. (BEM stands for Block Element Modifier).
You can read more about BEM here: https://css-tricks.com/bem-101/
and about 7-1 sass architecture: https://www.learnhowtoprogram.com/user-interfaces/building-layouts-preprocessors/7-1-sass-architecture
As I said HTML is the skeleton for your page, CSS is the muscles, skin and hair.
Hope it will help!
This comment was deleted 6 years ago
Thanks, Wessel!
Appreciate your time to reply here. I will look into this :)