It is possible to make Pseudo-Classes in CSS, by putting a tag name such as <li>, then a colon, then putting something like “first-child” afterwards. Putting that example together would look like “li:first-child” for the selector. This example would only apply the styling to the first child of any list.

In addition, you can put “nth-child” then, in parentheses, either “even” or “odd”, and the above example uses a list item would only apply the styling to either the even or the odd numbered list items.

There is also a misconception concerning Pseudo-Classes. If you were to try doing a nested styling that uses pseudo-classes, such as “article p:first-child”, then what would happen? Would the first child of a <p> tag inside an <article> tag be affected? Actually no it wouldn’t. In that circumstance, the very first child element of the <article> tag would be affected by the styling instead, if possible.

By Levi

Leave a Reply

Your email address will not be published. Required fields are marked *