Why is it difficult for you? Of course, sometimes it doesn’t work as expected, but I’ve finally set my IDE to spaces and automatically convert any tab in my sources and switch it to 4 spaces.
I use Komodo Edit (the free version) for Mac OS X and it works fine. Of course, in some older projects, it was very far from my goals…
Yes, we can write views, partial views or widgets so that they will produce a piece of HTML output that has a clean indentation. Some tools have clever functions to help us do it.
But once you have implanted a partial view or a widget in a view, and put the content view into the layout view, it’s impossible to maintain a clean indentation in the HTML output as a whole.
I once had a chance to read a code trying to produce a well indented HTML output as a whole.
In it, the HTML fragment codes had lengthy leading spaces so that they could fit well into the main code. And some utility subroutines had a parameter named ‘indent_depth’ in order to change the leading spaces. And what you’ve got after all is a set of source codes that are very hard to read and maintain.
Voted for #2. It’ll just leave me with the feeling of having written clean and reproducable code. As for the finalö output: I gave up on that a long time ago. If I generate (X)HTML via XSL/T, I tend to strip unimportant whitespaces alltogether. Pages compress a bit better that way.
Well I said gzip because I voted for max indentation, so that gives lots of useless spaces for the browser’s interpretation.
gzip (any?) compression algorithm should be effective because we’re talking about HTML (text) files.
My home page with very good HTML/CSS separation weighs 18,534 bytes for the HTML alone (230 lines). It’s gzipped to 5,256 bytes. With no indentation at all, the same HTML weighs 14,682 bytes. When gzipped, it’s 5,039 bytes.
See my point? 200 bytes are imho worth the indentation. And I’m not even using mod_deflate because I don’t have it on my shared host.
Now, according to my experience, sometimes proper HTML output indentation is necessary because a closing tag is possible to miss, and browser interpretations can vary, especially prior to HTML5 (which introduces optional closing tags by design). And Safari inspector (the one I use most for HTML) show only beautified/indented and even closed-tag HTML code, so it’s not the exact copy of the source. I think I remember FF has the same behavior… but maybe I’m wrong.
Yes, indeed. But in my experience, (X)HTML with all unnecessary whitespaces (that includes CRs, LFs and tabs) stripped tends to compress even better. It’s all about getting the last bit out of it
Imo with gzip on its not worth the stripping. 200 Bytes more just for white spaces even seems quite high to me. Even with a huge amount of visitors like wikipedia or youtube don’t bother with this.
Also if you consequently stip white spaces you will have to have 2 different view files one for editing and one (stripped) for publishing. Imho its not worth it for HTML.
I do care about indentation, but usually auto format works pretty well, so it’s not a big issue for me.
Yes, we sometimes have to examine the raw html output to debug. The raw html can have errors like missing opening/closing tags or overlapping tags. But those errors will be covered up by the browsers’ parser, and we will see only the corrected DOM tree.
So I admit that cleanly formatted raw html output has some advantage. But it is very small and not worth the effort. We can use our favorite editor to check the matching of tags, and it doesn’t matter how beautiful the html is indented when we do that kind of debugging.
for me indenting php and javascript codes is a must first. why it because these are the codes the produces the html code in your views(this is usually my case). And lastly indent the html code in your views… its really a torture to see a unindented code hahaha
anyways why indent the html output code? hahaha is there any good man can perfectly indent a html code after it is produced by server-side code to the client-side?
Well, you could pass it through tidy, which can repair broken HTML and take care about indentation at the same time. However, I found tidy’s output rarely statisfying