22.12.2013 Views

W3C CSS2 Cascading Style Sheets, level 2 - instructional media + ...

W3C CSS2 Cascading Style Sheets, level 2 - instructional media + ...

W3C CSS2 Cascading Style Sheets, level 2 - instructional media + ...

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Note. In <strong>CSS2</strong>, it is not possible to refer to attribute values for other<br />

elements of the selector.<br />

The ’display’ property controls whether the content is placed in a block, inline,<br />

or marker box.<br />

Authors should put ’content’ declarations in @<strong>media</strong> [p. 78] rules when the<br />

content is <strong>media</strong>-sensitive. For instance, literal text may be used for any <strong>media</strong><br />

group, but images only apply to the visual + bitmap <strong>media</strong> groups, and sound<br />

files only apply to the aural <strong>media</strong> group.<br />

Example(s):<br />

The following rule causes a sound file to be played at the end of a quotation<br />

(see the section on aural style sheets [p. 277] for additional mechanisms):<br />

@<strong>media</strong> aural {<br />

BLOCKQUOTE:after { content: url("beautiful-music.wav") }<br />

}<br />

Example(s):<br />

The next rule inserts the text of the HTML "alt" attribute before the image. If the<br />

image is not displayed, the reader will still see the "alt" text.<br />

IMG:before { content: attr(alt) }<br />

Authors may include newlines in the generated content by writing the "\A"<br />

escape sequence in one of the strings after the ’content’ property. This inserts a<br />

forced line break, similar to the BR element in HTML. See "Strings" [p. 50] and<br />

"Characters and case" [p. 38] for more information on the "\A" escape sequence.<br />

Example(s):<br />

H1:before {<br />

display: block;<br />

text-align: center;<br />

content: "chapter\A hoofdstuk\A chapitre"<br />

}<br />

Generated content does not alter the document tree. In particular, it is not fed<br />

back to the document language processor (e.g., for reparsing).<br />

Note. In future <strong>level</strong>s of CSS, the ’content’ property may accept additional<br />

values, allowing it to vary the style of pieces of the generated content, but in<br />

<strong>CSS2</strong>, all the content of the :before or :after pseudo-element has the same style.<br />

12.3 Interaction of :before and :after with<br />

’compact’ and ’run-in’ elements<br />

The following cases can occur:<br />

1. A ’run-in’ or ’compact’ element has a :before pseudo-element of type<br />

’inline’: the pseudo-element is taken into account when the size of the<br />

element’s box is computed (for ’compact’) and is rendered inside the same<br />

block box as the element.<br />

2. A ’run-in’ or ’compact’ element has an :after pseudo-element of type<br />

’inline’: The rules of the previous point apply.<br />

3. A ’run-in’ or ’compact’ element has a :before pseudo-element of type<br />

156

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!