Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.DS_Store
.zed
60 changes: 36 additions & 24 deletions index.html
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta
name="viewport"
content="width=device-width, initial-scale=1.0"
/>
<link rel="stylesheet" href="styles.css" />
<title>CSS Selector Fun</title>
</head>
<body>

</head>
<body>
<p>Make this text orange and 28px</p>
<p>Make this text orange and 28px</p>
<p>Make this text orange and 28px</p>
Expand All @@ -26,34 +28,44 @@ <h4>Make this heading pink</h4>
but also some slightly different styles. Is there a way we can avoid
repeating the common styles in the stylesheet? -->
<div class="container-one">
This text should stay black and 28px
<p>
Make this text <span>blue</span> and 12px. Make this paragraph have 10px left margin and a black 2px bottom border.
</p>
This text should stay black and 28px
<p>
Make this text
<span>blue</span>
and 12px. Make this paragraph have 10px left margin and a
black 2px bottom border.
</p>
</div>

<div class="container-two">
<span>This text should stay black and 28px.</span>
<p>
Make this text purple and 15px. Make this paragraph have 10px left margin and a black 1px bottom border.
<!-- We don't want to change all spans - just this one. How
can you use CSS to select this specific span, without modifying
<span>This text should stay black and 28px.</span>
<p>
Make this text purple and 15px. Make this paragraph have 10px
left margin and a black 1px bottom border.
<!-- We don't want to change all spans - just this one. How
can you use CSS to select this specific span, without modifying
the HTML file? -->
<span>Make this text 12px and grey.</span>
</p>
<span>Make this text 12px and grey.</span>
</p>
</div>

<!-- Is there a way to define a CSS selector that matches
elements that have multiple classes only? -->
<div class="container-one container-two">
<p>This text should be purple, 10px, all capitals and bold. Make this paragraph have 10px left margin and black 1px bottom border.</p>
<p>
This text should be purple, 10px, all capitals and bold. Make
this paragraph have 10px left margin and black 1px bottom
border.
</p>
</div>

<!-- How do you stop this element getting the styles from
<!-- How do you stop this element getting the styles from
the above elements? -->
<section class="container-one container-two">
<p>Make this <span>text orange and 28px.</span></p>
<p>
Make this
<span>text orange and 28px.</span>
</p>
</section>

</body>
</body>
</html>
71 changes: 71 additions & 0 deletions styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
* {
font-family: New York;
}

p {
color: orange;
font-size: 28px;
}

h1,
h2,
h3,
h4 {
color: pink;
}

.paragraph,
#paragraph {
color: green;
font-size: 28px;
}

#paragraph {
color: red;
}

.container-one {
font-size: 28px;
}

.container-one p {
margin-left: 10px;
border-bottom: 2px solid black;
}

.container-one p,
.container-one p span {
font-size: 12px;
color: blue;
}

.container-two {
font-size: 28px;
}

.container-two p {
color: purple;
margin-left: 10px;
font-size: 15px;
border-bottom: 1px solid black;
}

.container-two p span {
color: grey;
font-size: 12px;
}

.container-one.container-two {
color: purple;
font-size: 10px;
font-weight: bold;
text-transform: uppercase;
}

section p,
section p span {
color: orange !important;
font-size: 28px !important;
border-bottom: none !important;
text-transform: none !important;
}