A way that helper functions not produce XHTML but HTML?

I would like to use HTML 4.01 Strict, and used a DOCTYPE of it in my
application template. But look like when a style sheet is included by a
helper function

<%= stylesheet_link_tag ‘style’ %>

the code produced is XHTML:

is there a way to ask Rails to use HTML instead of XHTML?

On May 25, 5:48 am, SpringFlowers AutumnMoon <rails-mailing-
[email protected]> wrote:

is there a way to ask Rails to use HTML instead of XHTML?

Nope, while it has been discussed a few times this is not something
rails supports. there might be a plugin for this out there.

Fred

SpringFlowers AutumnMoon wrote:

I would like to use HTML 4.01 Strict, and used a DOCTYPE of it in my
application template.
[…]

Why? XHTML is definitely the way to go these days.

Best,

Marnen Laibow-Koser
http://www.marnen.org
[email protected]

Marnen Laibow-Koser wrote:

SpringFlowers AutumnMoon wrote:

I would like to use HTML 4.01 Strict, and used a DOCTYPE of it in my
application template.
[…]

Why? XHTML is definitely the way to go these days.

coz IE doesn’t support XHTML. So while we use XHTML, we are actually
using something that the majority of the client doesn’t understand.

SpringFlowers AutumnMoon wrote:

Marnen Laibow-Koser wrote:

SpringFlowers AutumnMoon wrote:

I would like to use HTML 4.01 Strict, and used a DOCTYPE of it in my
application template.
[…]

Why? XHTML is definitely the way to go these days.

coz IE doesn’t support XHTML. So while we use XHTML, we are actually
using something that the majority of the client doesn’t understand.
If I remember correctly, IE does support XHTML from version 6, if not
before, so long as you have the proper DOCTYPE declaration. I would
guess that quirksmpde.org would have more information.

All my webapps and static sites use XHTML, and they work fine in IE as
far as I know.

Best,

Marnen Laibow-Koser
http://www.marnen.org
[email protected]

Marnen Laibow-Koser wrote:

If I remember correctly, IE does support XHTML from version 6, if not
before, so long as you have the proper DOCTYPE declaration. I would
guess that quirksmpde.org would have more information.

I think on SitePoint and StackOverflow.com, they usually say XHTML is
not supported by IE 6, 7, 8.

Most web browsers have mature support[15] for all of the possible XHTML
media types.[16] The notable exception is Internet Explorer by
Microsoft; […] Microsoft developer Chris W. explained in 2005 that
IE7’s priorities were improved security and CSS support, and that proper
XHTML support would be difficult to graft onto IE’s
compatibility-oriented HTML parser.[19]

Marnen Laibow-Koser wrote:

The Wikipedia article seems to say that this is not really a problem if
the XHTML is served as text/html, which is what Rails does by default.

hm… so the XHTML will just be used as html… and we aim to output it
as XHTML anyway…

pragmatically, it will work… i just wonder why we don’t just output
what is really being accepted by most browsers.

SpringFlowers AutumnMoon wrote:
[…]

hm… so the XHTML will just be used as html…

Not really; the DOCTYPE still tells the browser that it’s XHTML.

and we aim to output it

as XHTML anyway…

pragmatically, it will work… i just wonder why we don’t just output
what is really being accepted by most browsers.

Most browsers have no problem. IE is the exception, sort of.

Anyway, XHTML is a cleaner standard than HTML – since it’s 100%
well-formed XML, it’s easier to parse and more extensible. There is
absolutely no reason not to use XHTML for all your output. You are
creating a problem out of thin air.

Best,

Marnen Laibow-Koser
http://www.marnen.org
[email protected]

SpringFlowers AutumnMoon wrote:
[…]

I think on SitePoint and StackOverflow.com, they usually say XHTML is
not supported by IE 6, 7, 8.

The Wikipedia article seems to say that this is not really a problem if
the XHTML is served as text/html, which is what Rails does by default.

Therefore, my advice would be this:

  • Use XHTML markup with appropriate DOCTYPE.
  • Serve as text/html.
  • Test with IE. Based on my own experience and the Wikipedia article,
    it will work in 99 cases out of 100.

Best,

Marnen Laibow-Koser
http://www.marnen.org
[email protected]

Marnen Laibow-Koser wrote:

SpringFlowers AutumnMoon wrote:
[…]

hm… so the XHTML will just be used as html…

Not really; the DOCTYPE still tells the browser that it’s XHTML.

except IE use it as HTML.

and we aim to output it

as XHTML anyway…

pragmatically, it will work… i just wonder why we don’t just output
what is really being accepted by most browsers.

Most browsers have no problem. IE is the exception, sort of.

Please note that MOST BROWSERS out there are IE. about 66%. So how do
you mean most browser has no problem when 66% of browsers have problem?

Anyway, XHTML is a cleaner standard than HTML – since it’s 100%
well-formed XML, it’s easier to parse and more extensible. There is
absolutely no reason not to use XHTML for all your output. You are
creating a problem out of thin air.

I hope you won’t accuse people of something. HTML is a standard. XHTML
is a standard. If some people want to use a particular standard, it is
not so bad as “creating a problem out of thin air”.

Marnen Laibow-Koser wrote:

Yes it is. HTML is an obsolescent standard, basically simply a matter
of backwards compatibility at this point. XHTML is the way forward, for
reasons I’ve already explained. If you follow the procedure I have
recommended, XHTML does not even cause problems with IE. That is a
fact. So why make more work for yourself by not using it?

mainly, i feel weird using something that 66% of browsers don’t
understand… so if I use HTML in some part of my code, and Rails
produce XHTML, then the final result won’t be able to validate.

SpringFlowers AutumnMoon wrote:

Marnen Laibow-Koser wrote:

SpringFlowers AutumnMoon wrote:
[…]

hm… so the XHTML will just be used as html…

Not really; the DOCTYPE still tells the browser that it’s XHTML.

except IE use it as HTML.

Perhaps…but better browsers will understand it for what it is. In
other words, it degrades gracefully.
[…]

Most browsers have no problem. IE is the exception, sort of.

Please note that MOST BROWSERS out there are IE. about 66%. So how do
you mean most browser has no problem when 66% of browsers have problem?

I was counting distinct programs, not total number of client
installations.

Anyway, it’s extremely dangerous to rely on across-the-board statistics
like these. It’s well established that different sites can have
wildly different browser usage figures.

Besides, IE’s market share is shrinking as more and more people
recognize it for the piece of crap it is.

[…]

I hope you won’t accuse people of something.

Huh?

HTML is a standard. XHTML
is a standard. If some people want to use a particular standard, it is
not so bad as “creating a problem out of thin air”.

Yes it is. HTML is an obsolescent standard, basically simply a matter
of backwards compatibility at this point. XHTML is the way forward, for
reasons I’ve already explained. If you follow the procedure I have
recommended, XHTML does not even cause problems with IE. That is a
fact. So why make more work for yourself by not using it?

Best,

Marnen Laibow-Koser
http://www.marnen.org
[email protected]

Marnen Laibow-Koser wrote:

The idea that it won’t be understood is simply false. Leaving aside the
questionable accuracy of the 66% figure,

it is a fact that all browsers
do understand XHTML served as I have outlined above – that is, the
way Rails does it by default!

so if i write

will IE close the div?

SpringFlowers AutumnMoon wrote:

Marnen Laibow-Koser wrote:

The idea that it won’t be understood is simply false. Leaving aside the
questionable accuracy of the 66% figure,

Usage share of web browsers - Wikipedia

Irrelevant. As I already explained, across-the-board statistics are
not useful here
.

it is a fact that all browsers
do understand XHTML served as I have outlined above – that is, the
way Rails does it by default!

so if i write

will IE close the div?

Self-closing container tags are basically the only risky XHTML syntax in
IE, as I understand it. I suggest you try this and see what you get.
If it turns out to be a problem, use

, which is valid HTML
and XHTML. I don’t think Rails’ helpers produce empty containers in any
case, so you’re safe.

Again: try it. If you have problems, then fix them. But most things
should Just Work, so don’t worry until something actually goes wrong.

Best,

Marnen Laibow-Koser
http://www.marnen.org
[email protected]

SpringFlowers AutumnMoon wrote:

mainly, i feel weird using something that 66% of browsers don’t
understand…

The idea that it won’t be understood is simply false. Leaving aside the
questionable accuracy of the 66% figure, it is a fact that all browsers
do understand XHTML served as I have outlined above – that is, the
way Rails does it by default!

This is why I say you’re creating a problem out of thin air: the fact is
that Rails’ default settings work for IE with no problem whatsoever
and no extra effort on your part.

If you don’t believe me on this point, try it and see for yourself.

so if I use HTML in some part of my code, and Rails
produce XHTML, then the final result won’t be able to validate.

Whether it will validate depends entirely on the DOCTYPE declaration.

Best,

Marnen Laibow-Koser
http://www.marnen.org
[email protected]

Rimantas L. wrote:
[snip]

Wow, where to begin? Your references are very interesting, but as I
read them, it seems to me that their authors have leapt to conclusions
from a farrago of spurious “facts” and unwarranted assumptions.

It is very unfortunate, that RoR chose this path. Especially now,
when some may want to use HTML5.

HTML 5 supports at least some of the XML-style syntax, including things
like “
”, so I wonder how much of a problem this would be in
practice.

I’ll try to write a detailed explanation of why your references really
don’t impress me, but for now let me just say that while they provide
some interesting information on the issues involved, I do not think that
they have sufficient credibility for their recommendations to be worth
following.

Best,

Marnen Laibow-Koser
http://www.marnen.org
[email protected]

Wow, where to begin? Â Your references are very interesting, but as I
read them, it seems to me that their authors have leapt to conclusions
from a farrago of spurious “facts” and unwarranted assumptions.

You can begin by reading apropriate specifications and trying things
out. Then you will very well see how “unwarranted” those assumptions
are.

It is very unfortunate, that RoR chose this path. Especially now,
when some may want to use HTML5.

HTML 5 supports at least some of the XML-style syntax, including things
like “
”, so I wonder how much of a problem this would be in
practice.

HTML5 supports two different modes of serialization. Once again
using XML brings nothing to the table if you use text/html.

I’ll try to write a detailed explanation of why your references really
don’t impress me, but for now let me just say that while they provide
some interesting information on the issues involved, I do not think that
they have sufficient credibility for their recommendations to be worth
following.

Well, even if names of Anne van Kesteren (Opera), Ian Hickson(Google,
author
and maintainer of Acid2 and Acid3 tests, editor of HTML5 spec),
Lachlan Hunt (Opera), Roger J. (prominent web standards advocate)
are not credible enough, you can always try for yourself and see.
I’ve done that five years ago: http://rimantas.com/bits/xhtml-test.php

It is trivial to test if DOCTYPE affects if page is processed with HTML
or
XHTML parser (it doesn’t) or is it only influenced by MIME type (it is).
Also it is not difficult to see that in XHTML mode CSS may be
interpreted
differently, Javascript is affected (just try to add line if (x<y) in
your
Javascript, do not escape it with CDATA and serve with
application/xhtml+xml.
You will see what I am talking about. Or try to wrap your JS code with

and see if it runs at all).

Regards,
Rimantas

http://rimantas.com/

This is a fairly retarded argument. Rails produces an XHTML
transitional doctype, so it’s all irrelevant.

If you want your own doctype, then type it in. It’s not hard.

Julian.


Learn: http://sensei.zenunit.com/
Last updated 20-May-09 (Rails, Basic Unix)
Blog: http://random8.zenunit.com/
Twitter: http://twitter.com/random8r

Not really; the DOCTYPE still tells the browser that it’s XHTML.

DOCTYPEs do not matter in this case. Browsers do switch
rendering modes depending on doctypes, but the only thing
that influences the choice of parser is MIME type [1]

Most browsers have no problem. Â IE is the exception, sort of.

All the browsers, IE or not, will treat XHTML document served as
text/html. And no, IE does not understand XHTML with
MIME type of text/xhtml+xml.
And yes, means completely different thing in
SGML and hence HTML. If browsers were treating this
correctly you’d see “>” scattered all over the “xhtml” documents.
Sure, no vendor will now risk to fix this.
By the way, Gecko 1.9 in source view shows “/” in red i.e.
as error if page uses xhtml syntax and is served with html
MIME type.

Anyway, XHTML is a cleaner standard than HTML – since it’s 100%
well-formed XML, it’s easier to parse and more extensible. Â There is
absolutely no reason not to use XHTML for all your output. Â You are
creating a problem out of thin air.

Except that all browser will parse your xhtml served as text/html with
their HTML parser, hence none of the above benefits will apply.

Semantically XHTML has no advantages over HTML 4—it is the
same spec reformulated in XML.
Serving with proper MIME type you will once again hit the problem
that IE does not support it. Also there are other issues, and sadly,
majority of XHTML users who chose it because “Zeldman told so”
are not aware about them [2,3,4].

It is very unfortunate, that RoR chose this path. Especially now,
when some may want to use HTML5.

[1] MIME types matter; DOCTYPEs don't — Anne’s Blog
[2] http://hixie.ch/advocacy/xhtml
[3]
The perils of using XHTML properly | 456 Berea Street
[4] http://lachy.id.au/log/2005/12/xhtml-beginners

Regards,
Rimantas

http://rimantas.com/

This is a fairly retarded argument. Rails produces an XHTML
transitional doctype, so it’s all irrelevant.

Did you read? Doctypes are relevant only for rendering modes
swithcing (quirks/standards), not for parsing engines (html/xml)
switching.

If you want your own doctype, then type it in. It’s not hard.

Oh thanks, this idea never occured to me.
Now the next part—how do I tell rails to stop polluting my code with
“/>”?

Regards,
Rimantas

http://rimantas.com/