[whatwg] A thought: <a href="..." method="post">

Ian Hickson wrote:
> On Fri, 6 May 2005, Ian Bicking wrote:
> 
>>A related extension might be a method attribute to anchor tags.  One might
>>expect <a href="form?delete=10" method="POST">[delete this]</a> to do a post
>>request to "form" with a request body of "delete=10".
> 
> 
> This has been brought up several times, although I don't remember the past 
> reasonings for it not being added to the spec.
> 
> The main problem I have with it is that it feels wrong. (Yup, I'm giving 
> really good arguments today!) The <a> element is supposed to be a 
> hyperlink -- but if you say it can be a form submission, that breaks that 
> model. Fundamentally, I feel users should be able to always treat 
> hyperlinks as safe-to-click -- they are links.
> 
> So I would say that any time an author needs something to have UI that is 
> a submission, it should be clearly submission UI. And that would be a 
> <button> or <input>, not an <a> hyperlink.
> 
> In short, I would say that <a href="delete">delete</a> is fundamentally 
> wrong.

I'd basically agree.  Which perhaps makes the argument stronger -- I 
agree, and yet when I'm actually writing an application I frequently do 
this anyway ;)  This is such a common practice, and at least 
method="post" offers a path to get people to move in the right 
direction.  Some of the motivations for using anchors is removed by Web 
Forms, but not entirely.

It's not 100% clear to me how you'd do the equivalent with <button>.  I 
guess this is what I'd come up with...

   <form action="form" method="post" id="delete"></form>
   ...
   <button form="delete" name="delete" value="10">delete this</button>

And that's not too bad.  If you really didn't want it to look like a 
button, you could go out of your way to use CSS to do that.  If the UA 
allowed it (if the UA actually allowed that).  But one major reasons for 
buttons not being used (besides currently requiring Javascript) is that 
they don't look very nice in long lists, so control over appearance is 
important.  But using anchors for actions is so engrained in web 
developers that it might not be enough of a carrot.

> But having said that, a lot of people have asked for this kind of thing. 
> Should we give up on our ideals in this particular case and just say that 
> the "method" attribute can change the <a> from being a simple hyperlink to 
> being part of a submission UI?

I must admit I don't know what you mean by "submission UI".  If you 
mean, act like a submit button for the containing form, then no, people 
use anchors specifically to avoid that.  Or do you mean something else?

-- 
Ian Bicking  /  ianb at colorstudy.com  / http://blog.ianbicking.org

Received on Friday, 6 May 2005 18:21:35 UTC