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

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
 
M

Mark Fitzpatrick

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"
 
L

Laurent Bugnion

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
 
T

Tony Girgenti

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
 
L

Laurent Bugnion, GalaSoft

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top