Learn HTML by Building a Cat Photo App - Step 14

Tell us what’s happening:
How do I add the target attribute with the value _blank?

Your code so far

<html>
  <body>
    <main>
      <h1>CatPhotoApp</h1>
      <h2>Cat Photos</h2>
      <!-- TODO: Add link to cat photos -->

<!-- User Editable Region -->

      <p>See more <a _blank href="https://freecatphotoapp.com">cat photos</a> in our gallery.</p>

<!-- User Editable Region -->

      <img src="https://cdn.freecodecamp.org/curriculum/cat-photo-app/relaxing-cat.jpg" alt="A cute orange cat lying on its back.">
    </main>
  </body>
</html>

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36

Challenge: Learn HTML by Building a Cat Photo App - Step 14

Link to the challenge:

Just like you did it with the “href” attribute and its value.

The target attribute is used in an HTML <a> (anchor) tag to specify where to open the linked document. The value of the target attribute can be one of the following:

  • _blank: Open the link in a new window or tab
  • _self: Open the link in the same window or tab (default value)
  • _parent: Open the link in the parent frame
  • _top: Open the link in the full body of the window

For example, if you want to open a linked document in a new window or tab, you would add the target attribute with a value of _blank to the <a> tag like this:

<a href="https://example.com" target="_blank">Link Text</a>

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