This forum is now read-only. Please use our new forums! Go to forums

0 points
Submitted by r mora
over 10 years

Full Monty or briefs?

In an earlier exercise we were taught that a p is targeted within nested divs like so: div div p. This seems to say that to target a nested element you should cite its full pedigree. Accordingly, in this exercise I used body ul li a to target the required a. This passes, but so does simple li a. Is the more elaborate selector better practice or is the simplified version good in all cases? Here’s the HTML for reference:

<!DOCTYPE html>
<html>
    <head>
        <link type="text/css" rel="stylesheet" href="stylesheet.css"/>
        <title>Linkapalooza</title>
    </head>
    <body>
        <a href="http://www.codecademy.com/">Codecademy!</a>
        <ul>
            <li>
                <a href="http://www.codecademy.com/learn">Learn</a>
            </li>
            <li>
                <a href="http://www.codecademy.com/create/creator">Teach</a>
            </li>
            <li>
                <a href="http://www.codecademy.com/edit_account/basic_info">Settings</a>
            </li>
        </ul>
    </body>
</html>

Answer 524c8c67f10c60fd920054f2

1 vote

Permalink

I would say that the elaborate version would be better practice, I have had doubts like this, that went through on the preview page, but it won’t let me submit it because I forgot something, like a colon during styling let’s say. Different computers have different processers, and honestly the creator put it that way for a reason, so I’d just say that you should leave it how he wants it, he knows more about this coding than you or I combined.

points
Submitted by Dillon Miller
over 10 years

Answer 5262bbf7f10c60b28500cd94

0 votes

Permalink

Thank you for your help… that cause me a little confusion :(

points
Submitted by Rose King
over 10 years