-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduction to CSS3: Mistake in an exercise or the code #6
Comments
Yes. However, I was thinking of the use of 'nth-child' selector. One could write a rule for 'p:nth-child(odd)' which should produce the desired outcome. (However, as the rule would also be applied to the - yet to be added - 7th, 9th etc. paragraphs, this might not be the ideal solution.) Maybe the assignment needs to be rephrased. |
I was not aware of the nth-child selector while I was working on that worksheet. It does indeed work but for some bizarre reason the CSS code: p:nth-child(odd) {
text-decoration: underline;
} underlines paragraphs number 2 and 4, while p:nth-child(even) underlines the correct paragraphs 1, 3, and 5. |
I believe there is either a mistake in the first task of the Test your understanding exercise or the code of selectors.html. The first task is as follows:
It asks you to add an underline to the 1st, 3rd, and 5th paragraphs with a single CSS rule. I believe this is impossible. The relevant HTML code for the selectors.html page where this underline is to be applied is as following (with the paragraphs numbered for clarity):
Because there is no difference between the 1st and 2nd paragraphs I do not think you can apply an underline to only the 1st paragraph in addition to the 3rd and the 5th with a single CSS rule.
Either the alert class was supposed to be applied to the 1st paragraph and not the header in the HTML code, or the task was supposed to ask for an underline on the header and the 3rd and 5th paragraphs.
The text was updated successfully, but these errors were encountered: