Help us understand the problem. What is going on with this article?

そういえばHTMLの属性って「"」か「'」どっちで囲めばいいの?

More than 3 years have passed since last update.

結論から言えば

Attributes are placed inside the start tag, and consist of a name and a value, separated by an "=" character. The attribute value can remain unquoted if it doesn’t contain space characters or any of " ' ` = < or >. Otherwise, it has to be quoted using either single or double quotes. The value, along with the "=" character, can be omitted altogether if the value is the empty string.

sample
<!-- empty attributes -->
<input name=address disabled>
<input name=address disabled="">

<!-- attributes with a value -->
<input name=address maxlength=200>
<input name=address maxlength='200'>
<input name=address maxlength="200">

W3C勧告 HTML5.1 HTMLの簡単な紹介 より

結論から言えば、どちらでもOK。

しかしなぜ、"ダブルクオーテーション"の方が普及率が高いのか……
W3C勧告にダブルクオーテーションが使用されているから、というのが有力かなーと思っているのですが……
調べてみましたが、結局結論に至れず。うーん…

NoxGit
得意料理 あんかけしょうがうどん
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away