:link

  • Revision slug: Web/CSS/:link
  • Revision title: :link
  • Revision id: 446647
  • Created:
  • Creator: teoli
  • Is current revision? No
  • Comment

Revision Content

{{ CSSRef() }}

Summary

The :link CSS pseudo-class lets you select links inside elements. This will select any link, even those already styled using selector with other link-related pseudo-classes like {{ cssxref(":hover") }}, {{ cssxref(":active") }} or {{ cssxref(":visited") }}. In order to style only non-visited links, you need to put the :link rule before the other ones, as defined by the LVHA-order: :link:visited:hover:active. The :focus pseudo-class is usually placed right before or right after :hover, depending of the expected effect.

Examples

a:link {color:slaygrate;}
.external:link {background-color:lightblue;}

Specifications

Specification Status Comment
{{ SpecName('CSS4 Selectors', '#link', ':link') }} {{ Spec2('CSS4 Selectors') }} No change.
{{ SpecName('CSS3 Selectors', '#link', ':link') }} {{ Spec2('CSS3 Selectors') }} No change.
{{ SpecName('CSS2.1', 'selector.html#link-pseudo-classes', ':link') }} {{ Spec2('CSS2.1') }} Lift the restriction to only apply it for {{ HTMLElement("a") }} element.
{{ SpecName('CSS1', '#anchor-pseudo-classes', ':link') }} {{ Spec2('CSS1') }} Initial definition.

Browser compatibility

{{ CompatibilityTable() }}

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support 1 {{ CompatGeckoDesktop("1") }} 3.0 3.5 1.0
Feature Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support 1.5 {{ CompatGeckoMobile("1.9.2") }} {{ CompatUnknown() }} {{ CompatUnknown() }} 3.2

See also

  • {{ cssxref(":visited") }}, {{ cssxref(":hover") }}, {{ cssxref(":active") }}

Revision Source

<p>{{ CSSRef() }}</p>
<h2 id="Summary">Summary</h2>
<p>The <code>:link</code> CSS <a href="/en/CSS/Pseudo-classes" title="Pseudo-classes">pseudo-class</a> lets you select links inside elements. This will select any link, even those already styled using selector with other link-related pseudo-classes like {{ cssxref(":hover") }}, {{ cssxref(":active") }} or {{ cssxref(":visited") }}. In order to style only <em>non-visited</em> links, you need to put the <code>:link</code> rule before the other ones, as defined by the <em>LVHA-order</em>: <code>:link</code> — <code>:visited</code> — <code>:hover</code> — <code>:active</code>. The <code>:focus</code> pseudo-class is usually placed right before or right after <code>:hover</code>, depending of the expected effect.</p>
<h2 id="Examples">Examples</h2>
<pre>a:link {color:slaygrate;}
.external:link {background-color:lightblue;}</pre>
<h2 id="Specifications">Specifications</h2>
<table class="standard-table">
  <thead>
    <tr>
      <th scope="col">Specification</th>
      <th scope="col">Status</th>
      <th scope="col">Comment</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>{{ SpecName('CSS4 Selectors', '#link', ':link') }}</td>
      <td>{{ Spec2('CSS4 Selectors') }}</td>
      <td>No change.</td>
    </tr>
    <tr>
      <td>{{ SpecName('CSS3 Selectors', '#link', ':link') }}</td>
      <td>{{ Spec2('CSS3 Selectors') }}</td>
      <td>No change.</td>
    </tr>
    <tr>
      <td>{{ SpecName('CSS2.1', 'selector.html#link-pseudo-classes', ':link') }}</td>
      <td>{{ Spec2('CSS2.1') }}</td>
      <td>Lift the restriction to only apply it for {{ HTMLElement("a") }} element.</td>
    </tr>
    <tr>
      <td>{{ SpecName('CSS1', '#anchor-pseudo-classes', ':link') }}</td>
      <td>{{ Spec2('CSS1') }}</td>
      <td>Initial definition.</td>
    </tr>
  </tbody>
</table>
<h2 id="Browser_compatibility" name="Browser_compatibility">Browser compatibility</h2>
<p>{{ CompatibilityTable() }}</p>
<div id="compat-desktop">
  <table class="compat-table">
    <tbody>
      <tr>
        <th>Feature</th>
        <th>Chrome</th>
        <th>Firefox (Gecko)</th>
        <th>Internet Explorer</th>
        <th>Opera</th>
        <th>Safari</th>
      </tr>
      <tr>
        <td>Basic support</td>
        <td>1</td>
        <td>{{ CompatGeckoDesktop("1") }}</td>
        <td>3.0</td>
        <td>3.5</td>
        <td>1.0</td>
      </tr>
    </tbody>
  </table>
</div>
<div id="compat-mobile">
  <table class="compat-table">
    <tbody>
      <tr>
        <th>Feature</th>
        <th>Android</th>
        <th>Firefox Mobile (Gecko)</th>
        <th>IE Mobile</th>
        <th>Opera Mobile</th>
        <th>Safari Mobile</th>
      </tr>
      <tr>
        <td>Basic support</td>
        <td>1.5</td>
        <td>{{ CompatGeckoMobile("1.9.2") }}</td>
        <td>{{ CompatUnknown() }}</td>
        <td>{{ CompatUnknown() }}</td>
        <td>3.2</td>
      </tr>
    </tbody>
  </table>
</div>
<h2 id="See_also">See also</h2>
<ul>
  <li>{{ cssxref(":visited") }}, {{ cssxref(":hover") }}, {{ cssxref(":active") }}</li>
</ul>
Revert to this revision