Exercise 10, different solution?


Stuck at exercise 10.

I have a question about linking the image. I have gotten it correct, but isn't there a nicer way?

I took the img> code and moved it to line 9 (the Learn More link) rather than surrounding line 23 (the img) with a>, and replaced the "Learn More" with the img which looked more visually appealing.
Why not just get rid of line 23 and just move the img code to the original "Learn More" link (line 9)? Both line 9 and line 23 have the href=" " and target="_blank"

<!DOCTYPE html>
  <title>Animals Around the World</title>
  <h1>The Brown Bear</h1>
  <p>The brown bear (Ursus arctos) is native to parts of northern Eurasia and North America. Its conservation status is currently "Least Concern." There are many subspecies within the brown bear species, including the Atlas bear and the Himalayan brown bear.</p>
  <a href="https://en.wikipedia.org/wiki/Brown_bear" target="_blank">Learn More</a>
  <p>The following are subspecies of bears:</p>
    <li>Nelsoni (extinct)</li>
  <p>The following countries have the largest populations of brown bears:</p>
    <li>United States</li>
  <a href="https://en.wikipedia.org/wiki/Brown_bear" target="_blank">
  <img src="https://s3.amazonaws.com/codecademy-content/courses/web-101/web101-image_brownbear.jpg" alt="A brown bear"/></a>


If you just wanted to make it less verbose your could use tiny URLs. The browser doesn't care how we compose it, so long as the HTML is well formed and the resources return 200 status. What the SCT expects is another layer on top of the browser.

Unless the instructions ask for it to be written this way, I would suggest wrapping the link in a P or a DIV. It's not good form to have inline elements directly in the BODY element. Normally we would house all body content in containers, all of which are block level. But, that could be just a style guide thing. I'm suspicious of how different browsers render inline elements, and put little faith in how normal flow will perceive them. Might be just me.


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.