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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
|
---
title: ':first-child'
slug: 'Web/CSS/:first-child'
tags:
- CSS
- Оформление
- Псевдоклас
- справочник
translation_of: 'Web/CSS/:first-child'
---
<div>{{CSSRef}}</div>
<p><span class="seoSummary"><a href="/bg/docs/Web/CSS">CSS</a> <a href="/bg/docs/Web/CSS/Pseudo-classes">псевдокласът</a> <code>:first-child</code> (:първо-дете) указва всеки елемент, намиращ се на първо място в списък с елементи от едно и също ниво в структурата на документа. В имплементациите на CSS3, за да бъде селектиран елемента, той трябва да има родител. В CSS4 това не е нужно.</span></p>
<h2 id="Правопис">Правопис</h2>
{{csssyntax}}
<h2 id="Примери">Примери</h2>
<h3 id="Пример_1">Пример 1</h3>
<h4 id="HTML">HTML</h4>
<pre class="brush: html"><div>
<p>This p is styled, as it is a p, AND the first
child in the div</p>
<p>This p is not styled; it is not the first child!</p>
</div>
<div>
<h2>This h2 is not styled; it is not a p!</h2>
<p>This p is not styled; it is not the first child!</p>
</div>
</pre>
<h4 id="CSS">CSS</h4>
<pre class="brush: css">p:first-child {
color: lime;
background-color: black;
padding: 5px;
}
</pre>
<h4 id="Резултат">Резултат</h4>
<p><span>{{EmbedLiveSample('Пример_1','100%',300)}}</span></p>
<h3 id="Пример_2_-_с_използване_на_UL">Пример 2 - с използване на UL</h3>
<h4 id="HTML_2">HTML</h4>
<pre class="brush: html"><ul>
<li>List 1</li>
<li>List 2</li>
<li>List 3</li>
</ul></pre>
<h4 id="CSS_2">CSS</h4>
<pre class="brush: css">li{
color:blue;
}
li:first-child{
color:green;
}</pre>
<h4 id="Резултат_2">Резултат</h4>
<p><span>{{EmbedLiveSample('Пример_2_-_с_използване_на_UL',300,100)}}</span></p>
<h2 id="Спецификации">Спецификации</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', '#first-child-pseudo', ':first-child')}}</td>
<td>{{Spec2('CSS4 Selectors')}}</td>
<td>Елементите няма нужда да имат родител за да бъдат селектирани.</td>
</tr>
<tr>
<td>{{SpecName('CSS3 Selectors', '#first-child-pseudo', ':first-child')}}</td>
<td>{{Spec2('CSS3 Selectors')}}</td>
<td>Без промяна.</td>
</tr>
<tr>
<td>{{SpecName('CSS2.1', 'selector.html#first-child', ':first-child')}}</td>
<td>{{Spec2('CSS2.1')}}</td>
<td>Начална дефиниция.</td>
</tr>
</tbody>
</table>
<h2 id="Съвместимост_на_четците">Съвместимост на четците</h2>
<div class="hidden">
<p>The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> and send us a pull request.</p>
</div>
<p>{{Compat("css.selectors.first-child")}}</p>
<h2 id="Вижте_също">Вижте също</h2>
<ul>
<li>{{cssxref(":last-child")}}</li>
<li>{{cssxref(":nth-child")}}</li>
<li>{{cssxref(":last-of-type")}}</li>
</ul>
|