css-diner icon indicating copy to clipboard operation
css-diner copied to clipboard

Lesson 15

Open thundercomander opened this issue 3 years ago • 5 comments

Can u correct description of example. "p:first-child" -> "p:first-child". I think space it is important.

thundercomander avatar Apr 06 '22 10:04 thundercomander

@Kanpaso, I believe it's the other way around. What's wrong is the answer to the exercise, not the example.

The :first-child selector should come immediately after the parent element, without whitespace.

Whitespace represents the descendant combinator, so no whitespace is allowed inside a compound selector.

Reference:

W3.org>selectors>white-space

image

bpires avatar Jun 04 '22 22:06 bpires

Actually, @Kanpaso, there's nothing wrong neither with the answer nor the example! I was completely wrong 😅

plate:first-child won't work because it will, in fact, trigger all plates that are a first-child of any element.

It's equivalent to say * > plate:first-child. Not what we are looking for.

By coincidence plate :first-child does work... but because the descendant combinator will point to all first-child elements in both plates. In our case, just our desired orange, as the first plate doesn't have any child.

Judging by the example though, I guess the expected answer here would be plate > orange:first-child, meaning the orange that is a first-child to a plate!

That was an unexpectedly tough one @flukeout!

Lessons learned.

image

bpires avatar Jun 04 '22 23:06 bpires

For me, selectors that are written like the examples, don't work. plate:first-child; neither plate :first-child and div plate:first-child

What am I doing wrong?

mariacrx avatar Jun 24 '22 17:06 mariacrx

@mariacrx In Level 15, there are no plates that are also the first child, so plate:first-child will not work.

Are you sure that plate :first-child (with a space) doesn't work? It's working for me and is an acceptable answer because it selects the first-child that is inside a plate element.

flukeout avatar Jun 24 '22 17:06 flukeout

plate > orange:first-child is good, and orange:first-child also, when de semicolon is missing.

KevinGIRAULT avatar Sep 12 '22 14:09 KevinGIRAULT