blob: ab3de8d5976d75a73d1b4c9e5b624820fd44fb6e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
|
---
title: Pseudo-elements
slug: Web/CSS/Pseudo-elements
translation_of: Web/CSS/Pseudo-elements
---
<div>{{CSSRef}}</div>
<p dir="rtl">یک CSS <strong>pseudo-element</strong> کلمه کلیدی است که به انتخابگر اضافه میشود و اجازه میدهد قسمت خاصی از عنصر انتخاب شده را آرایش کنید. برای مثال، {{ Cssxref("first-line::") }} میتواند برای تغییر نوشتار و رنگ خط اول یک پاراگراف مورد استفاده قرار گیرد.</p>
<pre class="brush: css no-line-numbers">/* The first line of every <p> element. */
p::first-line {
color: blue;
text-transform: uppercase;
}</pre>
<div class="note">
<p><strong>Note:</strong> In contrast to pseudo-elements, {{cssxref("pseudo-classes")}} can be used to style an element based on its <em>state</em>.</p>
</div>
<h2 id="Syntax">Syntax</h2>
<pre class="syntaxbox">selector::pseudo-element {
property: value;
}</pre>
<p>You can use only one pseudo-element in a selector. It must appear after the simple selectors in the statement.</p>
<div class="note">
<p><strong>Note:</strong> As a rule, double colons (<code>::</code>) should be used instead of a single colon (<code>:</code>). This distinguishes pseudo-classes from pseudo-elements. However, since this distinction was not present in older versions of the W3C spec, most browsers support both syntaxes for the original pseudo-elements.</p>
</div>
<h2 id="Index_of_standard_pseudo-elements">Index of standard pseudo-elements</h2>
<div class="index">
<ul>
<li>{{ Cssxref("::after") }}</li>
<li>{{ Cssxref("::before") }}</li>
<li>{{ cssxref("::cue")}}</li>
<li>{{ Cssxref("::first-letter") }}</li>
<li>{{ Cssxref("::first-line") }}</li>
<li>{{ Cssxref("::selection") }}</li>
<li>{{ Cssxref("::slotted") }}</li>
<li>{{ Cssxref("::backdrop") }} {{experimental_inline}}</li>
<li>{{ Cssxref("::placeholder") }} {{experimental_inline}}</li>
<li>{{ Cssxref("::marker") }} {{experimental_inline}}</li>
<li>{{ Cssxref("::spelling-error") }} {{experimental_inline}}</li>
<li>{{ Cssxref("::grammar-error") }} {{experimental_inline}}</li>
</ul>
</div>
<table class="standard-table">
<tbody>
<tr>
<th>Browser</th>
<th>Lowest Version</th>
<th>Support of</th>
</tr>
<tr>
<td rowspan="2">Internet Explorer</td>
<td>8.0</td>
<td><code>:pseudo-element</code></td>
</tr>
<tr>
<td>9.0</td>
<td><code>:pseudo-element ::pseudo-element</code></td>
</tr>
<tr>
<td rowspan="2">Firefox (Gecko)</td>
<td>1.0 (1.0)</td>
<td><code>:pseudo-element</code></td>
</tr>
<tr>
<td>1.0 (1.5)</td>
<td><code>:pseudo-element ::pseudo-element</code></td>
</tr>
<tr>
<td rowspan="2">Opera</td>
<td>4.0</td>
<td><code>:pseudo-element</code></td>
</tr>
<tr>
<td>7.0</td>
<td><code>:pseudo-element ::pseudo-element</code></td>
</tr>
<tr>
<td>Safari (WebKit)</td>
<td>1.0 (85)</td>
<td><code>:pseudo-element ::pseudo-element</code></td>
</tr>
</tbody>
</table>
<h2 id="See_also">See also</h2>
<ul>
<li><a href="/en-US/docs/Web/CSS/Pseudo-classes">pseudo-classes</a></li>
</ul>
|