
* a 要素・area 要素 coords 属性 (HTML, XHTML 1)

[1] [[HTML]] の [CODE(HTMLe)[[[a]]]] 要素および [CODE(HTMLe)[[[area]]]]
要素の [DFN[[CODE(HTMLa)[coords]] 属性]]は、
領域の位置と形を指定します。

[2] 仕様書:
[[HTML 4]] <IW:HTML4:"struct/objects.html#adef-coords">


** 属性値

[3] この属性の値は [CODE(SGML)[%[[Coords]]]] です。
[[SGML]] 的には [CODE(SGML)[[[CDATA]]]] です。

[4] この属性は省略可能です。

仕様書には明記されていませんが、 [CODE(HTMLe)[area]]
の場合 [CODE(HTMLa)[[[shape]]]] が [CODE(HTML)[[[default]]]]
以外なら必須、 [CODE(HTMLe)[a]] の場合 [CODE(HTML)[default]]
の場合と画像写像の領域にしない場合以外は必須と思われます。
(そうしなければ意味を成しません。)

** 歴史

*** 大域属性としての使用

[9] [[XHTML2]] では [CODE(HTMLa)@en[[[src]]]] の[[大域属性]]化に伴い
[CODE(HTMLa)@en[[[coords]]]] [[属性]]も[[大域属性]]となりました。

;; [CITE@en[- XHTML Attribute Collections]] ([TIME[2002-12-12 23:58:38 +09:00]] 版) <http://www.w3.org/TR/2002/WD-xhtml2-20021211/mod-attribute-collections.html#adef_attribute-collections_coords>

[10] 
[PRE(HTML example code)[
<html xmlns="http://www.w3.org/2002/06/xhtml2">
   <head>
      <title>The cool site!</title>
   </head> 
   <body>
     <p src="navbar1.png" type="image/png" usemap="#map1"> 
       <map id="map1">
         <nl>
           <label>Navigate the site:</label>
           <li href="guide.html" shape="rect" coords="0,0,118,28">
           Access Guide</li> 
           <li href="shortcut.html" shape="rect" coords="118,0,184,28">
           Go</li> 
           <li href="search.html" shape="circle" coords="184,200,60">
           Search</li>
           <li href="top10.html" shape="poly" coords="276,0,276,28,100,200,50,50,276,0">
           Top Ten</li>
         </nl>
       </map> 
      </p>
   </body>
</html> 
]PRE]

;; >>9 仕様案より

** メモ

[5]
[CITE@en-us[coords Property (A, AREA)]] ([CODE[2007-05-02 10:44:26 +09:00]] 版) <http://msdn2.microsoft.com/en-us/library/ms533695.aspx>
([[名無しさん]])

[6]
>>5

> For [CODE(HTMLe)@en[[[a]]]] objects, you must set the value of this property before you can retrieve it. This satisfies the requirements of World Wide Web Consortium (W3C) Document Object Model (DOM) Level 1 World Wide Web link. The page author is responsible for implementing the functionality defined in HTML 4.0 World Wide Web link for [CODE(HTMLe)@en[[[a]]]] objects, if desired.

意味がわからない。
([[名無しさん]] [WEAK[2007-05-02 01:49:01 +00:00]])

[7]
[CITE[Re: Image maps: should we drop <a coords="">?]] ([[Ian Hickson]] 著, [CODE[2007-08-06 21:22:19 +09:00]] 版) <http://permalink.gmane.org/gmane.org.w3c.whatwg.discuss/11585>

> Regarding <a coords="">, I don't think it's used any more now than when I 
decided not to include it in HTML5, so I'm still of the opinion that not 
including it is a good thing.

[8] [CITE[The SMIL 3.0 Linking Modules]] ([TIME[2008-12-02 00:45:09 +09:00]] 版) <http://www.w3.org/TR/2008/REC-SMIL3-20081201/smil-extended-linking.html#adef-coords>

[[#comment]]


* メモ

[11] [CITE[''''''[''''''whatwg'''''']'''''' Image maps: should we drop <a coords="">?]]
( ([TIME[2011-01-19 23:53:23 +09:00]] 版))
<http://lists.whatwg.org/htdig.cgi/whatwg-whatwg.org/2005-April/003508.html>

[12] [CITE@en[Revamp coords parsing to be more compatible and less insane · whatwg/html@ead6cfe]]
([TIME[2016-01-30 20:58:07 +09:00]] 版)
<https://github.com/whatwg/html/commit/ead6cfe392d338b66ed85fa84855061fd0990431>

[FIG(quote)[
[FIGCAPTION[
[13] [CITE@en[Google Maps JavaScript API V3 Reference  |  Google Maps JavaScript API  |  Google Developers]]
( ([TIME[2016-06-01 10:39:27 +09:00]]))
<https://developers.google.com/maps/documentation/javascript/reference?csw=1#MarkerShape>
]FIGCAPTION]

> Type:  Array<number>
> The format of this attribute depends on the value of the type and follows the w3 AREA coords specification found at http://www.w3.org/TR/REC-html40/struct/objects.html#adef-coords. 
> The coords attribute is an array of integers that specify the pixel position of the shape relative to the top-left corner of the target image. The coordinates depend on the value of type as follows: 
>   - circle: coords is '''['''x1,y1,r''']''' where x1,y2 are the coordinates of the center of the circle, and r is the radius of the circle. 
>   - poly: coords is '''['''x1,y1,x2,y2...xn,yn''']''' where each x,y pair contains the coordinates of one vertex of the polygon. 
>   - rect: coords is '''['''x1,y1,x2,y2''']''' where x1,y1 are the coordinates of the upper-left corner of the rectangle and x2,y2 are the coordinates of the lower-right coordinates of the rectangle.

]FIG]


[14] [CITE@en[Editorial: always state invalid value default]]
([[GloverDonovan]]著, [TIME[2018-03-05 13:36:29 +09:00]])
<https://github.com/whatwg/html/commit/7e941ae96b264d4743ea0afac00c3b3209ab0cde>