T
T
TomaZ Vazovsky2014-01-30 16:12:14
HTML
TomaZ Vazovsky, 2014-01-30 16:12:14

What is the more or less common and complete "code style" format for HTML?

Hello. Please share information. Do you know some more or less common and complete "code style" format for HTML? And which one do you personally use on your projects? Something like "PSR" or "Zend Code Style" for PHP.
I read the Google HTML/CSS Style Guide (though fluently), but didn't find an answer to my question, which I started searching for the format with: what to do with tags if they start to crawl out beyond 120 characters in length. It is clear that you can do nothing, but, in my opinion, it is so extreme that it is not convenient and not visual. You can somehow transfer. It is interesting, in this regard, who does what, and whether there is a more or less popular and proven system.
Also, speaking of the "Google HTML/CSS Style Guide", I always close tags that are optional (they require not to be closed). Maybe this is an anachronism inherited from XHTML, but it seems to me that the structure of the document is more visual. What do you say?
Please share your experience, ladies and gentlemen, who is not lazy))
ps let's immediately agree that we will not argue about "tabs vs spaces"))

Answer the question

In order to leave comments, you need to log in

3 answer(s)
K
Konstantin Dovnar, 2014-01-30
@SolidlSnake

I do not deny the charm of such style-guides (as a fan of Python and PEP8), but I have never adhered to anything like this in layout.
It is possible that in vain, I do not know.
My main rule has always been - just keep the documents clean, both HTML and CSS, so that in case something happens, I can return, tear out / peep a piece and calmly use / change it, without pain in one place.
In CSS, at the same time, I always tried to divide attributes into thematic ones, i.e. separated sizes, colors, etc. with an empty line.
Now, out of interest, I’ll go over the advice from Google, but I don’t think so. that I will change something in my personal rules.

M
Mikhail Shatilov, 2014-01-30
@iproger

I follow common standards like code alignment without mess. If html comes out, then I do nothing (without indents it goes up to 120). More than 160 does not happen in general.

N
Nazar Mokrinsky, 2014-01-30
@nazarpc

I don't close single tags

<img src="" alt="">
<input type="number">

I always close the steam rooms
Why? Because in the first it is absolutely not necessary, and in the second it is difficult to keep in mind which tags close which when opened, and a few characters of the closing tag are not worth the hemorrhoids that will result when the tag closes itself not where you expected.
In general, you rarely have to write clean html, and when you have to, I don’t remember that the lines were too long (if a little longer, I’d rather go beyond the border than make a step).
CSS is always sorted alphabetically. I don’t care about the meaning, I want to clearly know what z-indexwill happen at the end, and backgroundat the very beginning, and I don’t need to strain to divide all the rules into categories.
In general, the PhpStorm / WebStorm IDE has a reformat command that will adjust the structure to the format you need. For PHP, I don’t use it until there are not enough options for fine-tuning enough, but for CSS / HTML it fits perfectly. Tweaked with any indentation - it aligned everything under one style.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question