Any reason whatsoever for an extra refund after </html>?

Are there any microscopic reasons at all (outside of superstition) to add extra income after </html> in (X) HTML documents?

Is there any significant reason rather than stopping this habit? (For me, this looks a lot cleaner, with the last line number coinciding with the last bit of code, but I'm curious to know if there are any known consequences / possible effects between saving or not having an extra return, for example, since the last line is not interpreted or what- something like that.)

+4
source share
8 answers

This is just superstition. If I remember correctly, one of the early versions of IE (2 or 3) would throw an error if you didn’t have an extra line break, but I think it didn’t matter for some time.

+13
source

One reason is that some lazily-programmed parsers are programmed to read a line at a time using linefeed or carriage-return-line-feed, and if the data stream ends, it either will not parse the last line, or it just will fail. I tried some C compilers and some versions of Make will complain if the last line does not contain a line feed. Obviously this is not HTML, but the reason makes sense.

I always add an extra line out of habit for this reason.

+2
source

Do you use VCS? Historically, some version control systems moan about the missing line end at the end of the file; I believe this could be due to the fact that diff and patch were (initially) a bit fussy about this.

Not quite superstition; perhaps we could classify it as an outdated urban legend (a lot of people in this business).

+2
source

I always finish my files with line feeds.

At one time, I had an automatic tool that would combine all the JavaScript files in a directory into a single file (to save HTTP requests). This will break if the file does not end on a new line and also does not end with a semicolon. Since then I have finished the files with a new line.

In addition, if you use a command-line shell, such as bash, and you are a cat file; A new prompt will appear after the last character in the file, so it looks much better if it's a new line.

+2
source

Irrelevant

+1
source

No, as Patrick says, that doesn't matter. If you want, the whole page can be on one line.

+1
source

Of course, no modern well-known browser will take care. Indeed, in HTML, unlike XHTML, the </html> tag is also superfluous.

However, in your first sentence you ask for microscopic reasons, and I have it. Some editors (I think there was one notepad, I haven’t checked lately) will automatically add CR / LF to the last line of the file when saving, if the line is not empty, perhaps to fix problems such as DevelopersDevelopersDevelopers describes. This was a real annoyance when editing DOS batch files as an extra line, which could adversely affect the completion of the script.

As a result, if you create your HTML in one editor that does not do this, and you do not add the final CR / LF manually, then later someone opens a file in the editor that does not change anything and save, you will get The error difference that may appear when looking for real changes or in version control logs.

In your second sentence, you pose significant reasons. This is not so, IMO, a significant reason, and I, of course, will worry about such a marginal case.

+1
source

I do not think there is a good reason. Perhaps without returning less data is transferred so that you can save traffic. But I don’t think it matters at all :-)

0
source

All Articles