Forum Moderators: open

Message Too Old, No Replies

Simple HTML question

Are line breaks required, or can it be one long line?

         

jaeden

3:35 pm on Jul 16, 2002 (gmt 0)

10+ Year Member



In an HTML file, do there have to be line breaks, or can there be just one realllllly long record?

Sinner_G

3:36 pm on Jul 16, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Looooooong record is ok as long as all the tags are there. Just think of the poor guys (maybe yourself) who have to do changes/updates to you code.

korkus2000

3:37 pm on Jul 16, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



View source at msn.com. They generate their pages and make about 10 really loooooong lines.

smokin

3:39 pm on Jul 16, 2002 (gmt 0)

10+ Year Member



A long record is ok as long as all tags are nested properly (bit of a pain to debug though) and the page can be validated.

smokin

jaeden

3:40 pm on Jul 16, 2002 (gmt 0)

10+ Year Member



Actually what I'm doing is creating a standard HTML page with tags such as %item1%. Then I'm coding a Java Servlet which will read the HTML file into one long string. Once I have that string I can do a string.replace, exchanging %item1% for that actual value. After replacing all the fields, I'm going to write the string one time to the print writer which will produce the page. So the only poor soul who would have to read and edit the code would be the one that copies it from 'view source'.

korkus2000

3:41 pm on Jul 16, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I usually keep my generated pages on as few lines as I can. It confuses my compotention :)

jaeden

3:45 pm on Jul 16, 2002 (gmt 0)

10+ Year Member



Thanks for all of the prompt answers guys!

rewboss

8:31 pm on Jul 16, 2002 (gmt 0)

10+ Year Member



It can be useful to do that if your code is long (you can, in this way, compress it by something like 30% in severe cases), but it's advisable to keep a copy of the "uncompressed" file in case you need to edit it.

I do have an application somewhere which does this (it's called HTMLShrinker). I downloaded it ages ago, found it to be quite clever but never had any reason to use it. As I recall, it automatically generates backups of the originals for you.

There is one potential trap you have to watch out for. Suppose you have text links at the bottom of your page that look like this:

Home Sales Order Contact

...and you've written the <a> tags like this:

<a href="index.html">Home</a>
<a href="sales.html">Sales</a>
<a href="order.html">Order</a>
<a href="contact.html">Contact</a>

(one on each line). That's okay, because the line breaks are converted into spaces. But if your application (like my HTMLShrinker) removes line breaks completely and only converts multiple spaces or tabs into (single) spaces, your links will look like this:

HomeSalesOrderContact

...not what you want. I got around that by putting a space at the beginning of each line if I didn't want it to run straight into the previous line (and, although I have never used HTMLShrinker on a published website, I haven't got out of that habit!). Your application might have been programmed more carefully, of course.

jaeden

9:38 pm on Jul 16, 2002 (gmt 0)

10+ Year Member



Thanks for the warning. I usually use the &nbsp; tag if I am really worried about things being crammed together.

piskie

12:05 am on Jul 17, 2002 (gmt 0)

10+ Year Member



I have seen it before and apart from a smaller file size, browsers seem to speed up without the interuptions of line breaks (ALTWIT).