aboutsummaryrefslogtreecommitdiff
path: root/files/de/web/css/_colon_first-child/index.html
blob: 150c836d1774575ba50734444ad6446b5b13d07d (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
98
99
100
101
102
103
---
title: ':first-child'
slug: 'Web/CSS/:first-child'
tags:
  - CSS
  - CSS Pseudoklasse
  - Layout
  - Referenz
  - Web
translation_of: 'Web/CSS/:first-child'
---
<div>{{CSSRef}}</div>

<h2 id="Übersicht">Übersicht</h2>

<p>Die <code>:first-child</code> <a href="/de/docs/Web/CSS">CSS</a> <a href="/de/docs/Web/CSS/Pseudo-classes">Pseudoklasse</a> repräsentiert jedes Element, das das erste Kindelement seines Elternelements ist.</p>

<h2 id="Syntax">Syntax</h2>

<pre class="syntaxbox">element:first-child { <em>Stileigenschaften</em> }
</pre>

<h2 id="Beispiele">Beispiele</h2>

<h3 id="Beispiel_1">Beispiel 1</h3>

<h4 id="HTML_Inhalt">HTML Inhalt</h4>

<pre class="brush: html">&lt;div&gt;
  &lt;span&gt;Dieser Text ist grün!&lt;/span&gt;
  &lt;span&gt;Dieser Text nicht. :(&lt;/span&gt;
&lt;/div&gt;
</pre>

<h4 id="CSS_Inhalt">CSS Inhalt</h4>

<pre class="brush: css">span:first-child {
    background-color: lime;
}
</pre>

<p>... sieht folgendermaßen aus:</p>

<p><span>{{EmbedLiveSample('Beispiel_1',300,50)}}</span></p>

<h3 id="Beispiel_2_-_Verwendung_von_UL">Beispiel 2 - Verwendung von UL</h3>

<h4 id="HTML_Inhalt_2">HTML Inhalt</h4>

<pre class="brush: html">&lt;ul&gt;
  &lt;li&gt;Eintrag 1&lt;/li&gt;
  &lt;li&gt;Eintrag 2&lt;/li&gt;
  &lt;li&gt;Eintrag 3&lt;/li&gt;
&lt;/ul&gt;</pre>

<h4 id="CSS_Inhalt_2">CSS Inhalt</h4>

<pre class="brush: css">li{
  color:red;
}
li:first-child{
  color:green;
}</pre>

<p>... sieht folgendermaßen aus:</p>

<p><span>{{EmbedLiveSample('Beispiel_2_-_Verwendung_von_UL',300,100)}}</span></p>

<h2 id="Spezifikationen">Spezifikationen</h2>

<table class="standard-table">
 <thead>
  <tr>
   <th scope="col">Spezifikation</th>
   <th scope="col">Status</th>
   <th scope="col">Kommentar</th>
  </tr>
 </thead>
 <tbody>
  <tr>
   <td>{{SpecName('CSS4 Selectors', '#first-child-pseudo', ':first-child')}}</td>
   <td>{{Spec2('CSS4 Selectors')}}</td>
   <td>Keine Änderung</td>
  </tr>
  <tr>
   <td>{{SpecName('CSS3 Selectors', '#first-child-pseudo', ':first-child')}}</td>
   <td>{{Spec2('CSS3 Selectors')}}</td>
   <td>Ursprüngliche Definition</td>
  </tr>
 </tbody>
</table>

<h2 id="Browser_Kompatibilität">Browser Kompatibilität</h2>

{{Compat("css.selectors.first-child")}}

<h2 id="Siehe_auch">Siehe auch</h2>

<ul>
 <li>{{cssxref(":last-child")}}</li>
 <li>{{cssxref(":nth-child")}}</li>
 <li>{{cssxref(":last-of-type")}}</li>
</ul>