Is there a recommended HTML / CSS / JavaScript style guide?

My team is trying to agree with the general HTML / CSS / Javascript style guide. I found the JavaScript JavaScript Style Guide , but nothing like HTML or CSS.

I am particularly interested in whether there are recommended naming conventions and naming conventions that are commonly used.

+6
source share
6 answers

Google now has its own HTML and CSS style guide: https://google.imtqy.com/styleguide/htmlcssguide.html.

+5
source

For JavaScript, use the Standard style .

js-standard-style

+3
source

In terms of CSS, this is good: http://woork.blogspot.com/2008/11/useful-guidelines-to-improve-css-coding.html

The touch that I add to my CSS is a tab, I think that nested elements should be labeled, for example:

table { } tr { } td { } 

You can also use a combination of name concatenation and tabs with css, for example.

 .main { } .main-title { } .main-title > h1 { } .main-content { } 

I just found an interesting article about CSS name: http://woork.blogspot.com/2008/11/css-coding-semantic-approach-in-naming.html There are links to 10 different CSS frameworks and 11 articles of articles about names CSS articles.

For JavaScript, I think the google style guide you posted is good.

+1
source

user approach used today for some html / css tutorial, object oriented css . Personally, I don’t like the way it “makes” you use some structures / names, but if your team is big, this is definitely the way to go!

0
source

Read this:

https://developer.mozilla.org/En/Mozilla_Coding_Style_Guide

there is no such guide to the style of HTML and CSS, you have to learn yourself.
this link may be useful to you.

Another way is to use validator to check the code

0
source

I have never heard of HTML / CSS, and I'm not sure if you really need it.

The main theme of style guides is to quickly read code using familiar visual layouts and naming conventions, so that developers know that they are doing something, because that’s the way they would put it / name it. HTML / CSS offers far fewer options for changing the way it works than a complex language like JavaScript. HTML, which is markup and strictly nested, creates a specific layout, and CSS has only one code construct, so you are left with names that, since they do not describe actions and do not process data, rarely require very complex ones.

As for JavaScript, as in any language, you need to choose a set of standards and stick to them. It doesn't really matter which of them will always love the other. Consistency is key, so the only thing you need to look for is a collection that matches the multitude of any large libraries you work with. One project I'm working on has its own rules for PHP, which should also be used for JavaScript. This makes it weird when camelCase () is used in the library code, and other code uses the words _separated_by_underscores () for function names.

Another minor issue may be that your favorite IDE may or may not have good support to enforce a specific set of standards through its automatic formatting / error. One-click fixes for inaccurate code are sometimes a real luxury!

0
source

Source: https://habr.com/ru/post/908135/


All Articles