Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><code>@</code> has been around since the days of <code>@import</code> in CSS1, although it's arguably becoming increasingly common in the recent <code>@media</code> (CSS2, CSS3) and <code>@font-face</code> (CSS3) constructs. The <code>@</code> syntax itself, though, as I mentioned, is not new.</p> <p>These are all known in CSS as <strong>at-rules</strong>. They're special instructions for the browser, not directly related to styling of (X)HTML/XML elements in Web documents using rules and properties, although they do play important roles in controlling how styles are applied.</p> <p>Some code examples:</p> <pre class="lang-css prettyprint-override"><code>/* Import another stylesheet from within a stylesheet */ @import url(style2.css); /* Apply this style only for printing */ @media print { body { color: #000; background: #fff; } } /* Embed a custom web font */ @font-face { font-family: 'DejaVu Sans'; src: local('DejaVu Sans Regular'), url(/fonts/DejaVuSans.ttf); } </code></pre> <ul> <li><p><a href="http://www.w3.org/TR/css3-fonts/#font-face-rule" rel="noreferrer"><code>@font-face</code> rules</a> define custom fonts for use in your designs that aren't always available on all computers, so a browser downloads a font from the server and sets text in that custom font as if the user's computer had the font.</p></li> <li><p><a href="http://www.w3.org/TR/css3-conditional/#at-media" rel="noreferrer"><code>@media</code> rules</a>, in conjunction with <a href="http://www.w3.org/TR/css3-mediaqueries" rel="noreferrer">media queries</a> (formerly only <a href="http://www.w3.org/TR/CSS21/media.html" rel="noreferrer">media types</a>), control which styles are applied and which aren't based on what media the page is being displayed in. In my code example, only when printing a document should all text be set in black against a white (the paper) background. You can use media queries to filter out print media, mobile devices and so on, and style pages differently for those.</p></li> </ul> <p>At-rules have no relation to <a href="http://www.w3.org/TR/selectors" rel="noreferrer">selectors</a> whatsoever. Because of their varying nature, different at-rules are defined in different ways across numerous different modules. More examples include:</p> <ul> <li><a href="http://www.w3.org/TR/css3-conditional" rel="noreferrer">Conditional rules</a></li> <li><a href="http://www.w3.org/TR/css3-animations" rel="noreferrer">Keyframe animations</a></li> <li><a href="http://www.w3.org/TR/css3-page" rel="noreferrer">Paged media</a></li> </ul> <p><em>(this list is far from exhaustive)</em></p> <p>You can find another non-exhaustive list at <a href="https://developer.mozilla.org/en-US/docs/CSS/At-rule" rel="noreferrer">MDN</a>.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload