[Proposal] Changing default value of open to true in the tag method in ActionView::Helpers::TagHelper

Helpers such as image_tag and stylesheet_link_tag use tag internaly. I am getting lots of info messages from the W3C HTML validator telling me that

Trailing slash on void elements has no effect and interacts badly with unquoted attribute values.

I propose changing

def tag(name = nil, options = nil, open = false, escape = true)

to

def tag(name = nil, options = nil, open = true, escape = true)

in the repo here

A side benefit would be that fewer bits are transmitted to the end user. In Greece, the government gives out grants for websites, requiring that the W3C validator and WAVE tester return no messages.

I traced this default back to the initial commit of the repository.

interacts badly with unquoted attribute values

This is a non-issue since the tag method will always generate quoted attributes.

A side benefit would be that fewer bits are transmitted to the end user

This is not a serious benefit since the number of void elements isn’t that many and we are talking about just one byte for each void element used.


If Rails were a greenfield framework would a different default be better? Maybe. But given it is not, this means changing the default to have the inverse meaning probably means a config option so those using XHTML can still use the old default. Adding that config option means it’s something everyone upgrading to the next version of Rails will need to consider. Is the new default ok or do they need to stick with the old default? This is a lot of decisions all for a change that doesn’t really offer any value.

In Greece, the government gives out grants for websites, requiring that the W3C validator and WAVE tester return no messages.

There is nothing stopping you from overriding the default. Add the following to your application_helper.rb:

def tag name=nil, options=nil, open=true, escape=true
  super
end

I think that should flip the default for your application.