# Rails and HTML 4.01 (not XHTML)

**URL:** <https://www.ruby-forum.com/t/rails-and-html-4-01-not-xhtml/106406>\
**Category:** Rails\
**Created:** [June 10, 2007, 1:29am UTC](https://www.ruby-forum.com/t/rails-and-html-4-01-not-xhtml/106406 "2007-06-10T01:29:05Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![hdante](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/e0b2c6/32.png) [@hdante](https://www.ruby-forum.com/u/hdante)\
**Post date:** [June 10, 2007, 1:29am UTC](https://www.ruby-forum.com/t/rails-and-html-4-01-not-xhtml/106406/1 "2007-06-10T01:29:05Z")

</div>

Hi,

I’ve tried to change my layouts to HTML 4.01 DOCTYPE, but then the  
page didn’t pass w3 validation. Validation fails in the line that  
corresponds to the following:

\<%= stylesheet\_link\_tag “depot”, :media =\> “all” %\>

This is rendered as

Change the final “/\>” to “\>” and the page is validated.

Are you sure HTML 4.01 is allowed ? How can I make  
stylesheet\_link\_tag and other constructs to correctly produce HTML  
4.01 output ? It would be really nice if I fully converted my pages to  
HTML 4.01.

Any help ? Thanks,

---

<div class="post-metadata">

**Author:** ![hdante](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/e0b2c6/32.png) [@hdante](https://www.ruby-forum.com/u/hdante)\
**Post date:** [April 17, 2008, 6:08am UTC](https://www.ruby-forum.com/t/rails-and-html-4-01-not-xhtml/106406/2 "2008-04-17T06:08:00Z")

</div>

calling back an old one - perhaps better than starting a new thread for  
an  
unfinished topic though.  
so how does one successfully use a HTML 4.01 strict DOCTYPE with rails  
helpers and hope to validate? i added the following to my  
application\_helper  
file which seems to do the trick for stylesheets but this is trying a  
symptom

def other\_stylesheet\_link\_tag(\*sources)  
out = stylesheet\_link\_tag sources  
out.sub(/\ /\>$/, ‘\>’)  
end

stylesheet\_link\_tag calls stylesheet\_tag which calls tag

tag has an open argument to leave tags open, but unfortunately there  
isn’t  
any way to access it from stylesheet\_link\_tag. any other suggestions?  
\<

> **[ActionView::Helpers::TagHelper](https://api.rubyonrails.org/classes/ActionView/Helpers/TagHelper.html#M001032)**
>
> Provides methods to generate HTML tags programmatically both as a modern HTML5 compliant builder style and legacy XHTML compliant tags.

> 

cheers,  
jean-pierre

---

<div class="post-metadata">

**Author:** ![hdante](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/e0b2c6/32.png) [@hdante](https://www.ruby-forum.com/u/hdante)\
**Post date:** [September 22, 2008, 3:39pm UTC](https://www.ruby-forum.com/t/rails-and-html-4-01-not-xhtml/106406/3 "2008-09-22T15:39:59Z")

</div>

Too funny that I just figured out the same thing. Why is Rails  
generating this additional character?
