Expand your HTML skills through an MDN Fellowship - Apply by April 1 http://mzl.la/MDNFellowship

mozilla

Revision 630991 of <a>

  • Revision slug: Web/HTML/Element/A
  • Revision title: <a>
  • Revision id: 630991
  • Created:
  • Creator: teoli
  • Is current revision? خیر
  • توضیح HTML/Element/A Web/HTML/Element/A

Revision Content

 

Аннотация

The anchor (<a>) element создает гиперссылку, место назначения гиперссылки, или и то, и другое.

Атрибуты

accesskey
Этот атрибут определяет "горячую клавишу" для элемента. Нажимая ALT или аналогичную клавишу (зависит от браузера и операционной системы) вместе с указанной клавишей выделяет ссылку, соотнесенную с этой клавишей.
charset
Этот атрибут определяет кодировку ресурса, на который ссылается документ. Значение - разделенный запятыми или пробелами список кодировок, указанных в RFC 2045. Значением по умолчанию является ISO-8859-1.
coords
For use with object shapes, this attribute uses a comma-separated list of numbers to define the coordinates of the object on the page.
datafld
This attribute specifies the column name from that data source object that supplies the bound data. This attribute is specific to Microsoft's Data Binding in Internet Explorer 4. dataFld Property (MSDN)
datasrc
This attribute indicates the id of the data source object that supplies the data that is bound to this element. This attribute is specific to Microsoft's Data Binding in Internet Explorer 4. dataSrc Property (MSDN)
href
Это единственный обязательный атрибут для ссылок. Он указывает назначение ссылки, либо URL, либо фрагмент URL, that is a name preceded by a hash mark (#), which specifies an internal target location within the current document. URLs are not restricted to Web (http)-based documents. URLs might use any protocol supported by the browser. For example, file, ftp, and mailto work in most user agents.
hreflang
This attribute is used to indicate the language of the linked resource. See "Language Reference," earlier in this appendix for information on allowed values.
methods
The value of this attribute provides information about the functions that might be performed on an object. The values generally are given by the HTTP protocol when it is used, but it might (for similar reasons as for the title attribute) be useful to include advisory information in advance in the link. For example, the browser might choose a different rendering of a link as a function of the methods specified; something that is searchable might get a different icon, or an outside link might render with an indication of leaving the current site. This element is not well understood nor supported, even by the defining browser, Internet Explorer 4. Methods Property (MSDN)
ping {{ Fx_minversion_inline(3) }}
If present, this attribute should be a space-separated list of URIs that wish to be notified when the user follows the hyperlink. Firefox sends a POST request to each HTTP URI in the list. The ping attribute's functionality can be enabled by setting the browser.send_pings preference to true. Поддержка "ping" была удалена начиная с Firefox 3 beta 3 ({{ Bug(415168) }}).
name
This attribute is required in an anchor defining a target location within a page. A value for name is similar to a value for the id core attribute and should be an alphanumeric identifier unique to the document. Under the HTML 4.01 specification, id and name both can be used with the <a> element as long as they have identical values.
rel
For anchors containing the href attribute, this attribute specifies the relationship of the target object to the link object. The value is a comma-separated list of relationship values. The values and their semantics will be registered by some authority that might have meaning to the document author. The default relationship, if no other is given, is void. The rel attribute should be used only when the href attribute is present.
rev
This attribute specifies a reverse link, the inverse relationship of the rel attribute. It is useful for indicating where an object came from, such as the author of a document.
shape
This attribute is used to define a selectable region for hypertext source links associated with a figure to create an image map. The values for the attribute are circle, default, polygon, and rect. The format of the coords attribute depends on the value of shape. For circle, the value is x,y,r where x and y are the pixel coordinates for the center of the circle and r is the radius value in pixels. For rect, the coords attribute should be x,y,w,h. The x,y values define the upper-left-hand corner of the rectangle, while w and h define the width and height respectively. A value of polygon for shape requires x1,y1,x2,y2,... values for coords. Each of the x,y pairs define a point in the polygon, with successive points being joined by straight lines and the last point joined to the first. The value default for shape requires that the entire enclosed area, typically an image, be used.

Note: It is advisable to use the usemap attribute for the img element and the associated map element to define hotspots instead of the shape attribute.

tabindex
This attribute uses a number to identify the object's position in the tabbing order for keyboard navigation using the TAB key.
target
This attribute specifies the target window for a hypertext source link that references frames. The information linked to target will be displayed in the named window. Frames and inline frames must be named to be targeted. There are, however, special name values. These include _blank, which indicates a new window; _parent, which indicates the parent frame set containing the source link; _self, which indicates the frame containing the source link; and _top, which indicates the full browser window.
type
This attribute specifies the media type in the form of a MIME type for the link target. Generally, this is provided strictly as advisory information; however, in the future a browser might add a small icon for multimedia types. For example, a browser might add a small speaker icon when type is set to audio/wav. For a complete list of recognized MIME types, see http://www.w3.org/TR/html4/reference...#ref-MIMETYPES.
urn
This supposedly Microsoft-supported attribute relates a uniform resource name (URN) with the link. While it is based on standards work years back, the meaning of URNs is still not well defined, so this attribute is meaningless. urn Property (MSDN)

Пример

    <!-- anchor linking to external file -->
<a href="http://www.mozilla.com/">
    External Link
</a>

Результат

External Link

Примечания

The following are reserved browser key bindings for the two major browsers and should not be used as values to accesskey: a, c, e, f, g, h, v, left arrow, and right arrow.

HTML 3.2 включает только name, href, rel, rev и title.

Атрибут target не работает в браузерах, не поддерживающих фреймы, таких как Netscape 1 generation. Кроме того, target не допускается в "строгих" (Strict) вариантах XHTML, но разрешен в формах frameset или "переходный" (transitional).

{{ HTML:Element_Navigation() }}

 

 

{{ languages( { "en": "en/HTML/Element/a", "es": "es/HTML/Element/a", "fr": "fr/HTML/Element/a", "ja": "ja/HTML/Element/a", "pl": "pl/HTML/Element/a" } ) }}

Revision Source

<p>&nbsp;</p>
<h3 id="Summary" name="Summary">Аннотация</h3>
<p>The <em>anchor</em> (<code>&lt;a&gt;</code>) element создает гиперссылку, место назначения гиперссылки, или и то, и другое.</p>
<h3 id="Attributes" name="Attributes">Атрибуты</h3>
<dl>
 <dt>
  accesskey</dt>
 <dd>
  Этот атрибут определяет "горячую клавишу" для элемента. Нажимая ALT или аналогичную клавишу (зависит от браузера и операционной системы) вместе с указанной клавишей выделяет ссылку, соотнесенную с этой клавишей.</dd>
</dl>
<dl>
 <dt>
  charset</dt>
 <dd>
  Этот атрибут определяет кодировку ресурса, на который ссылается документ. Значение - разделенный запятыми или пробелами список кодировок, указанных в <a class="external" href="http://tools.ietf.org/html/rfc2045" title="http://tools.ietf.org/html/rfc2045">RFC 2045</a>. Значением по умолчанию является ISO-8859-1.</dd>
</dl>
<dl>
 <dt>
  coords</dt>
 <dd>
  For use with object shapes, this attribute uses a comma-separated list of numbers to define the coordinates of the object on the page.</dd>
</dl>
<dl>
 <dt>
  datafld</dt>
 <dd>
  This attribute specifies the column name from that data source object that supplies the bound data. This attribute is specific to Microsoft's Data Binding in Internet Explorer 4. <a class="external" href="http://msdn.microsoft.com/en-us/library/ms533703(VS.85).aspx">dataFld Property (MSDN)</a></dd>
</dl>
<dl>
 <dt>
  datasrc</dt>
 <dd>
  This attribute indicates the id of the data source object that supplies the data that is bound to this element. This attribute is specific to Microsoft's Data Binding in Internet Explorer 4. <a class="external" href="http://msdn.microsoft.com/en-us/library/ms533709(VS.85).aspx">dataSrc Property (MSDN)</a></dd>
</dl>
<dl>
 <dt>
  href</dt>
 <dd>
  Это единственный обязательный атрибут для ссылок. Он указывает назначение ссылки, либо URL, либо фрагмент URL, that is a name preceded by a hash mark (#), which specifies an internal target location within the current document. URLs are not restricted to Web (http)-based documents. URLs might use any protocol supported by the browser. For example, file, ftp, and mailto work in most user agents.</dd>
</dl>
<dl>
 <dt>
  hreflang</dt>
 <dd>
  This attribute is used to indicate the language of the linked resource. See "Language Reference," earlier in this appendix for information on allowed values.</dd>
</dl>
<dl>
 <dt>
  methods</dt>
 <dd>
  The value of this attribute provides information about the functions that might be performed on an object. The values generally are given by the HTTP protocol when it is used, but it might (for similar reasons as for the title attribute) be useful to include advisory information in advance in the link. For example, the browser might choose a different rendering of a link as a function of the methods specified; something that is searchable might get a different icon, or an outside link might render with an indication of leaving the current site. This element is not well understood nor supported, even by the defining browser, Internet Explorer 4. <a class="external" href="http://msdn.microsoft.com/en-us/library/ms534168(VS.85).aspx">Methods Property (MSDN)</a></dd>
</dl>
<dl>
 <dt>
  ping {{ Fx_minversion_inline(3) }}</dt>
 <dd>
  <strike>If present, this attribute should be a space-separated list of URIs that wish to be notified when the user follows the hyperlink. Firefox sends a POST request to each HTTP URI in the list. The <code>ping</code> attribute's functionality can be enabled by setting the <code>browser.send_pings</code> preference to <code>true</code>.</strike> Поддержка "ping" была удалена начиная с Firefox 3 beta 3 ({{ Bug(415168) }}).</dd>
</dl>
<dl>
 <dt>
  name</dt>
 <dd>
  This attribute is required in an anchor defining a target location within a page. A value for name is similar to a value for the id core attribute and should be an alphanumeric identifier unique to the document. Under the HTML 4.01 specification, id and name both can be used with the &lt;a&gt; element as long as they have identical values.</dd>
</dl>
<dl>
 <dt>
  rel</dt>
 <dd>
  For anchors containing the href attribute, this attribute specifies the relationship of the target object to the link object. The value is a comma-separated list of relationship values. The values and their semantics will be registered by some authority that might have meaning to the document author. The default relationship, if no other is given, is void. The rel attribute should be used only when the href attribute is present.</dd>
</dl>
<dl>
 <dt>
  rev</dt>
 <dd>
  This attribute specifies a reverse link, the inverse relationship of the rel attribute. It is useful for indicating where an object came from, such as the author of a document.</dd>
</dl>
<dl>
 <dt>
  shape</dt>
 <dd>
  This attribute is used to define a selectable region for hypertext source links associated with a figure to create an image map. The values for the attribute are circle, default, polygon, and rect. The format of the coords attribute depends on the value of shape. For circle, the value is x,y,r where x and y are the pixel coordinates for the center of the circle and r is the radius value in pixels. For rect, the coords attribute should be x,y,w,h. The x,y values define the upper-left-hand corner of the rectangle, while w and h define the width and height respectively. A value of polygon for shape requires x1,y1,x2,y2,... values for coords. Each of the x,y pairs define a point in the polygon, with successive points being joined by straight lines and the last point joined to the first. The value default for shape requires that the entire enclosed area, typically an image, be used.</dd>
</dl>
<p><em>Note</em>: It is advisable to use the usemap attribute for the img element and the associated map element to define hotspots instead of the shape attribute.</p>
<dl>
 <dt>
  tabindex</dt>
 <dd>
  This attribute uses a number to identify the object's position in the tabbing order for keyboard navigation using the TAB key.</dd>
</dl>
<dl>
 <dt>
  target</dt>
 <dd>
  This attribute specifies the target window for a hypertext source link that references frames. The information linked to target will be displayed in the named window. Frames and inline frames must be named to be targeted. There are, however, special name values. These include _blank, which indicates a new window; _parent, which indicates the parent frame set containing the source link; _self, which indicates the frame containing the source link; and _top, which indicates the full browser window.</dd>
</dl>
<dl>
 <dt>
  type</dt>
 <dd>
  This attribute specifies the media type in the form of a MIME type for the link target. Generally, this is provided strictly as advisory information; however, in the future a browser might add a small icon for multimedia types. For example, a browser might add a small speaker icon when type is set to audio/wav. For a complete list of recognized MIME types, see <a class="external" href="http://www.w3.org/TR/html4/references.html#ref-MIMETYPES" rel="freelink">http://www.w3.org/TR/html4/reference...#ref-MIMETYPES</a>.</dd>
</dl>
<dl>
 <dt>
  urn</dt>
 <dd>
  This supposedly Microsoft-supported attribute relates a uniform resource name (URN) with the link. While it is based on standards work years back, the meaning of URNs is still not well defined, so this attribute is meaningless. <a class="external" href="http://msdn.microsoft.com/en-us/library/ms534710(VS.85).aspx">urn Property (MSDN)</a></dd>
</dl>
<h3 id="Example" name="Example">Пример</h3>
<pre>
    &lt;!-- anchor linking to external file --&gt;
&lt;a href="http://www.mozilla.com/"&gt;
    External Link
&lt;/a&gt;
</pre>
<h4 id="Result" name="Result">Результат</h4>
<p><a class="external" href="http://www.mozilla.com/">External Link</a></p>
<h3 id="Notes" name="Notes">Примечания</h3>
<p>The following are reserved browser key bindings for the two major browsers and should not be used as values to accesskey: a, c, e, f, g, h, v, left arrow, and right arrow.</p>
<p>HTML 3.2 включает только <strong>name</strong>, <strong>href</strong>, <strong>rel</strong>, <strong>rev</strong> и <strong>title</strong>.</p>
<p>Атрибут <strong>target</strong> не работает в браузерах, не поддерживающих фреймы, таких как Netscape 1 generation. Кроме того, target не допускается в "строгих" (Strict) вариантах <a href="/en/XHTML" title="en/XHTML">XHTML</a>, но разрешен в формах frameset или "переходный" (transitional).</p>
<p>{{ HTML:Element_Navigation() }}</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>{{ languages( { "en": "en/HTML/Element/a", "es": "es/HTML/Element/a", "fr": "fr/HTML/Element/a", "ja": "ja/HTML/Element/a", "pl": "pl/HTML/Element/a" } ) }}</p>
Revert to this revision