In the specification, I noticed entries like this:

<form action="/find.cgi" method=post enctype="multipart/form-data"> <input type=text name=t> <input type=search name=q> <input type=submit> </form> 

It turns out the values ​​can not be wrapped in quotes, if they do not contain specials. characters.

But where is this opportunity spelled out?

html.spec.whatwg.org

  • It is possible, but it is better to wrap it up - andreymal Nov.
  • @andreymal why? - A. Gusev Nov.
  • Because you can not put a space, it considers that this is another attribute ( value="Моя надпись" => Моя надпись ; value=Моя надпись => Моя ) - Yuri
  • @Yuri Pro spaces are understandable. The rest is very convenient. - A. Gusev

1 answer 1

Yes that's right. The specification describes three options for writing attribute values:

Here

Specifically about writing without quotes, this part says:

Unquoted attribute value syntax

This is the name of the attribute name, must not contain any literal space characters (U) + 0022 QUOTATION MARK characters ("), U + 0027 APOSTROPHE characters ('), U + 003D EQUALS SIGN characters (=), U + 003C U + 003E GREATER-THAN SIGN characters (>), or U + 0060E ACCENT characters (`),


The following is the syntax of the attribute value syntax:

 <input value=yes> 

If you want to use the tag, it’s not necessary to make it so that you can use it.

Where it says that the value should not contain spaces, double and single quotes, gravises, triangular brackets. And this applies not only to values ​​without quotes.

Those. value without quotes can contain all the same values ​​as usual. The record from your example can be written like this:

 <form action=/find.cgi method=post enctype=multipart/form-data> <input type=text name=t> <input type=search name=q> <input type=submit> </form> 
  • one
    Well, you could copy the text and paste it as a quote, not a picture - Grundy
  • @Grundy I'll do it next time :) - A. Gusev