1 <!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.0 Strict//EN"
2 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3 <html xmlns=
"http://www.w3.org/1999/xhtml" xml:
lang=
"en" lang=
"en">
5 <meta http-equiv=
"content-type" content=
"text/html; charset=utf-8" />
6 <title>Safari CSS2 :after test
</title>
7 <style type=
"text/css">
8 /* the following styles are for general layout purposes;
9 they are not required for the purposes of this example */
11 border:1px solid
#000;
30 <h1>Problem: Safari improperly handles generated content in certain cases when used with multiple class names
</h1>
31 <p><em>When referencing an element by two class names simultaneously, Safari won't generate content (using :before or :after) within the element.
</em></p>
32 <p>Assume we have a
<code>div
</code> with two class names:
<code>box
</code> and
<code>one
</code>. Within that
<code>div
</code>, we have a
<code>p
</code> (paragraph) tag, after which we'd like to insert generated content. One way to do so would be the following:
</p>
33 <pre class=
"error"><code>div.box.one p:after{ content:'generated content here!'; }
</code></pre>
34 <p>But that doesn't work in Safari. However, if you drop one of the class names, as shown below, it works as expected:
</p>
35 <pre class=
"ok"><code>div.box p:after{ content:'generated content here!'; }
</code></pre>
36 <p>Note also that the bug only applies to content
<em>within
</em> the classed element
— generating content
<em>before or after the element itself
</em> works fine:
</p>
37 <pre class=
"ok"><code>div.box.one:after{ content:'generated content here!'; }
</code></pre>
41 <!-- all code necessary for the example, including CSS, is below: -->
43 <h2>Example (view source to see CSS and HTML):
</h2>
44 <style type=
"text/css">
46 content:'generated content';
51 content:'generated content';
57 <p>Both boxes below should contain generated content (
<span style=
"color:green;">in green
</span>):
</p>
61 <p>This box should contain the text
"generated content" in CSS2-compliant browsers (but won't in Safari).
</p>
66 <p>This box should contain the text
"generated content" in CSS2-compliant browsers, including Safari.
</p>