Forum Moderators: open

Message Too Old, No Replies

ignore *all* whitespace around tags - how?

ignore whitespace, pretty printing

         

joat

7:25 pm on Nov 3, 2003 (gmt 0)

10+ Year Member



Hi. Is there a way to write XHTML such that the browsers ignore *all* whitespace around tags? I.e. I need to pretty print an XHTML file such that each tag is on its own line (with proper indentation), but then those newlines, tabs and spaces I use end up in the rendering as space!

How do I pretty print the way I want, and yet make sure those spaces don't have an effect on rendering?

Thanks - joat

tedster

3:09 am on Nov 4, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Welcome to WebmasterWorld, joat.

Could you give us a short example of the kind of code that's giving you problems?

joat

3:35 am on Nov 4, 2003 (gmt 0)

10+ Year Member



Hi tedster,

An example:
===
<b>
This is bold text
</b>
, and this a comma and a continuation.
===
The comma was supposed to show up *right after* text like this: "text," and not with a space like this: "text ," But by default it shows up with a space.

Again, the desired result is to have all tags in the source XHTML file on separate lines from the text being displayed. I need to view and process the source XHTML file with tags & text on separate lines without the need of an (X)HTML parser.

thx - joat

DrDoc

3:40 pm on Nov 4, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



There's no way of doing what you want without a parser.

There's a space before/after the tag, so the browser will render one. Why? Because you put the space there, so the browser figured you wanted it ;)