Is it OK to put carriage returns in web form HTML view ?

  • Thread starter Thread starter Tony Girgenti
  • Start date Start date
T

Tony Girgenti

Hello.

When i look at a web form in design view, i have the option to view the
HTML. Some of the HTML code is in one long string and hard to read.

Is it OK to put in carriage returns and blank lines in the HTML so that is
is easier to read ?

I'm not talking about changing the HTML code logic, just the readability of
it.

Any help would be gratefully appreciated.

Thanks,
Tony
 
Sure. You can break up an HTML tag as you need to and the browser won't
care. ASP.Net tags can also be broken up to span multiple lines. For
readibilities sake, I tend not to break up in the middle of an attribute
value unless it's really lone like the text property of a control. The
browsers are designed to ignore any extra whitespace other than one space so
you could break a signle HTML tag up to take as many lines as you need such
as:

<img
src="myimage.gif"
width = "100"
height="100"
 
Hi,

Tony said:
Hello.

When i look at a web form in design view, i have the option to view the
HTML. Some of the HTML code is in one long string and hard to read.

Is it OK to put in carriage returns and blank lines in the HTML so that is
is easier to read ?

I'm not talking about changing the HTML code logic, just the readability of
it.

Any help would be gratefully appreciated.

Thanks,
Tony

A carriage return in HTML is rendered as a white space by the browser.
That can be annoying sometimes. For example if you want to place two
SPANs next to each other without any space, you cannot do this:

<span ...></span>
<span ...></span>

but you can do this:

<span ...></span><span
....></span>

If you choose carefully how to place your carriage returns, you won't
have a problem.

HTH,
Laurent
 
Thanks for your replies.

Laurent Bugnion said:
Hi,



A carriage return in HTML is rendered as a white space by the browser.
That can be annoying sometimes. For example if you want to place two SPANs
next to each other without any space, you cannot do this:

<span ...></span>
<span ...></span>

but you can do this:

<span ...></span><span
...></span>

If you choose carefully how to place your carriage returns, you won't have
a problem.

HTH,
Laurent
--
Laurent Bugnion, GalaSoft
Software engineering: http://www.galasoft-LB.ch
PhotoAlbum: http://www.galasoft-LB.ch/pictures
Support children in Calcutta: http://www.calcutta-espoir.ch
 
Hi,

Mark said:
Sure. You can break up an HTML tag as you need to and the browser won't
care. ASP.Net tags can also be broken up to span multiple lines. For
readibilities sake, I tend not to break up in the middle of an attribute
value unless it's really lone like the text property of a control. The
browsers are designed to ignore any extra whitespace other than one space so
you could break a signle HTML tag up to take as many lines as you need such
as:

<img
src="myimage.gif"
width = "100"
height="100"

I usually don't break attributes either, but there are notable exceptions:

<div style="color: Red;
background-color: Blue;
font-size: 2em;"

onclick="alert( 'Hello' );
alert( 'World' );">...</div>

HTH,
Laurent
 
Back
Top