Skip to content

Commit e9a034c

Browse files
committed
Added :first-child, :last-child and :nth-child pseudo classes to the css styles. For styling last paragraph of the article and also first and last list items.
1 parent 66a494f commit e9a034c

File tree

2 files changed

+34
-2
lines changed

2 files changed

+34
-2
lines changed

starter/03-CSS-Fundamentals/index.html

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ <h3>What is HTML?</h3>
7979
<p>In HTML, each element is made up of 3 parts:</p>
8080

8181
<ol>
82-
<li>The opening tag</li>
82+
<li class="first-li">The opening tag</li>
8383
<li>The closing tag</li>
8484
<li>The actual element</li>
8585
</ol>
@@ -101,7 +101,9 @@ <h3>Why should you learn HTML?</h3>
101101
</p>
102102

103103
<ul>
104-
<li>To be able to use the fundamental web dev language</li>
104+
<li class="first-li">
105+
To be able to use the fundamental web dev language
106+
</li>
105107
<li>
106108
To hand-craft beautiful websites instead of relying on tools
107109
like Worpress or Wix

starter/03-CSS-Fundamentals/style.css

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,3 +95,33 @@ aside {
9595
a {
9696
color: azure;
9797
} */
98+
99+
/* .first-li {
100+
font-weight: bold;
101+
} */
102+
103+
li:first-child {
104+
font-weight: bold;
105+
}
106+
107+
li:last-child {
108+
font-style: italic;
109+
}
110+
111+
li:nth-child(even) {
112+
/* color: red; */
113+
}
114+
115+
/*
116+
this will not work because paragraph is not the first child of our article
117+
118+
article p:first-child {
119+
color: red;
120+
}
121+
*/
122+
123+
/* but this is gonna work, because paragraph is the last child of our article */
124+
125+
article p:last-child {
126+
color: red;
127+
}

0 commit comments

Comments
 (0)