View Full Version : hey you html gurus (carriage return)
george
12-18-2004, 03:17 PM
hi html people. as you know, a carriage return (enter key) in html equals a space (when the html is displayed in a web browser). so:
h
e
l
l
o
is displayed as:
h e l l o
while manually writiing your site in a program such as notepad (i know most of you do that), youl use the enter key to keep the code organized and readable... the problem is, as i said before, an enter key is a space - this can cause inaccurate display of your website. now my question:
there is a way to put carriage returns without causing a space. i know this because Microsoft Frontpage does this, if I am not mistaken. But how the heck do you do it?? I searched google but couldn't find any answer.
Thanks!
Mickey Crocker
12-18-2004, 03:45 PM
<br /> This breaks the text
and
<p> Text here </p>
george
12-18-2004, 03:55 PM
i know that :-) . i mean when pressing the enter key in a text editor. enter produce a space. i am looking for a carriage return that does not effect the html. just like the TAB key, it lets you indent your code without effecting the web page.
Tom Cain
12-18-2004, 04:16 PM
A carriage return in HTML will always result in a space. Any whitespace character, or string of whitespace characters, will be displayed as a single space in a web browser. This includes the tab character. Tabs do indent the HTML text, but they also affect the HTML display because they are converted into a single space.
Heh. You just need an text editor which (optionally) wraps long text (without inserting CR/LFs).
Textpad(.com) for example can do that.
svero
12-18-2004, 06:47 PM
http://www.htmlcodetutorial.com/linepar/_NOBR.html
I don't think it's very reliable though. I might be more inclined to use some php or something to organize my output in a manner I can follow.
Dan MacDonald
12-18-2004, 07:07 PM
You can also wrap the whole thing in <pre>
<pre>
h
e
l
l
o
</pre>
which stands for "pre formatted" IIRC
Chris Evans
12-18-2004, 08:26 PM
Neat freaks. :)
george
12-18-2004, 09:48 PM
thanks for all the info guys. i kind of figured it out...
this is what i was doing before:
hello
<br><br>
how are you?
the proper way to avoid a whitespace:
hello<br><br>
how are you
according to the standards, carriage returns after the closing tag will be ignored. technically, <br> is a closing tag I guess.
and i don't think TAB casuses a whitespace. I use TAB all the time in my pages (for organization) and I don't see any whitespaces...
one more question, what's up with adding /> at the end of tags now, like <br/>? is this a new standard? what is the difference/benefit?
Dan MacDonald
12-18-2004, 10:29 PM
It just converts html into well formatted XML. Thus becomming XHTML. Or, html that is also valid XML document.
svero
12-19-2004, 01:09 AM
Oh and by the way.. if your pages have a bunch of double BR's in them then I consider looking at the <P> tag -- I only say that because i use to use double <br> everywhere.
The problem I see with <p> is that it doesn't do the same thing on all browsers. <br> have a more consistent behaviour :).
The problem I see with <p> is that it doesn't do the same thing on all browsers. <br> have a more consistent behaviour :).
In my experience IE and Netscape are highly inconsistent in how they handle <br> tags when paired with almost any other construct ( <li> tags, <table> tags, etc. and <p> tags as well although that's moot since ideally you wouldn't be using any <p>'s if you're using all <br>'s) ... so yea... I guess that's not really accurate either. :)
Web browsers remind me of the english language. Every rule has exceptions, and most of the exceptions have exceptions too. ;)
If you really care about how the output looks when rendered in a browser, you should learn to use cascading style sheets. Either that, or use Flash.
--milo
http://www.starshatter.com
vBulletin v3.6.0, Copyright ©2000-2008, Jelsoft Enterprises Ltd.