Reputation: 370
I have been given the following multiple choice question:
- Which CSS selector applies to all div tags within the ID called “red”:
A. red blue
B. div #red
C. red div
D. $red div
I was not sure which one worked, so first I did some Googling, and read the relevant articles on W3Schools, but I still couldn't see an example using any of the styles listed above.
So I tried writing up an html document with a CCS style element in the header, and tried all 4 of the given answers. However none of them seem to work for me.
<!DOCTYPE html>
<html>
<head>
<style>
red blue {
border: 1px solid red;
}
</style>
</head>
<body>
<div id="red">
<p>Hello world!</p>
</div>
</body>
</html>
The above code for A. gave no border. When line 5 was changed to div #red {
, then red div {
, then $red div
, there was still no border shown.
Am I being stupid? Or is there a typo? Any help would be appreciated.
Upvotes: 0
Views: 57
Reputation: 871
Are you sure the B) option is div (space) #red? Because the correct answer is div#red (note, no space). So if the B) option is "div (space) #red" then there's a typo in the answers, yes
EDIT: My bad, I read the question as "with the ID called red", not "within the ID red". In that case, the proper answer is "#red div"
Upvotes: 3