Skip to content

Commit

Permalink
Fix lint issues (#28163)
Browse files Browse the repository at this point in the history
* Fix lint issues

* Fix lint issues
  • Loading branch information
asdacosta committed Jun 12, 2024
1 parent 4eb944a commit 299a037
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions foundations/html_css/html-foundations/links-and-images.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ The `noopener` value prevents the opened link from gaining access to the webpage

Why do we need this added behaviour for opening links in new tabs? Security reasons. The prevention of access that is caused by `noopener` prevents [phishing attacks](https://www.ibm.com/topics/phishing) where the opened link may change the original webpage to a different one to trick users. This is referred to as [tabnabbing](https://owasp.org/www-community/attacks/Reverse_Tabnabbing). Adding the `noreferrer` value can be done if you wish to not let the opened link know that your webpage links to it.

Note that you may be fine if you forget to add `rel="noopener noreferrer"` since more recent versions of browsers [provide this security](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#security_and_privacy) if only `target="_blank"` is present. Nevertheless, in line with good coding practices and to err on the side of caution, it is recommended to always pair a `target="_blank"` with a `rel="noopener noreferrer"`.
Note that you may be fine if you forget to add `rel="noopener noreferrer"` since more recent versions of browsers [provide security](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#security_and_privacy) if only `target="_blank"` is present. Nevertheless, in line with good coding practices and to err on the side of caution, it is recommended to always pair a `target="_blank"` with a `rel="noopener noreferrer"`.

### Absolute and relative links

Expand Down Expand Up @@ -163,17 +163,20 @@ Instead of wrapping content with an opening and closing tag, it embeds an image
For example, using an absolute path we can display an image located on The Odin Project site:

<p class="codepen" data-height="300" data-theme-id="dark" data-default-tab="html,result" data-slug-hash="gORbExZ" data-user="TheOdinProjectExamples" style="height: 300px; box-sizing: border-box; display: flex; align-items: center; justify-content: center; border: 2px solid; margin: 1em 0; padding: 1em;">

<span>See the Pen <a href="https://codepen.io/TheOdinProjectExamples/pen/gORbExZ">
absolute-path-image</a> by TheOdinProject (<a href="https://codepen.io/TheOdinProjectExamples">@TheOdinProjectExamples</a>)
on <a href="https://codepen.io">CodePen</a>.</span>

</p>

<script async src="https://cpwebassets.codepen.io/assets/embed/ei.js"></script>

To use images that we have on our own websites, we can use a relative path.

<details markdown="block">
<summary class="dropDown-header">Linux, macOS, ChromeOS
</summary>

<summary class="dropDown-header">Linux, macOS, ChromeOS</summary>

1. Create a new directory named `images` within the `odin-links-and-images` project.
1. Next, [download our practice image](https://unsplash.com/photos/Mv9hjnEUHR4/download?force=true&w=640) and move it into the images directory we just created.
Expand All @@ -182,8 +185,8 @@ To use images that we have on our own websites, we can use a relative path.
</details>

<details markdown="block">
<summary class="dropDown-header">WSL2
</summary>

<summary class="dropDown-header">WSL2</summary>

When you download a file from the internet, Windows has a security feature that creates a hidden `Zone.Identifier` file with the same name as your downloaded file and it looks like `mypicture.jpg:Zone.Identifier` This file is harmless, but we'd like to avoid copying it over and cluttering up our directories.

Expand Down Expand Up @@ -255,10 +258,13 @@ The alt attribute is used to describe an image. It will be used in place of the
This is how the The Odin Project logo example we used earlier looks with an alt attribute included:

<p class="codepen" data-height="300" data-theme-id="dark" data-default-tab="html,result" data-slug-hash="ExXjoEp" data-user="TheOdinProjectExamples" style="height: 300px; box-sizing: border-box; display: flex; align-items: center; justify-content: center; border: 2px solid; margin: 1em 0; padding: 1em;">

<span>See the Pen <a href="https://codepen.io/TheOdinProjectExamples/pen/ExXjoEp">
image-alt-attribute</a> by TheOdinProject (<a href="https://codepen.io/TheOdinProjectExamples">@TheOdinProjectExamples</a>)
on <a href="https://codepen.io">CodePen</a>.</span>

</p>

<script async src="https://cpwebassets.codepen.io/assets/embed/ei.js"></script>

As a bit of practice, add an alt attribute to the dog image we added to the `odin-links-and-images` project.
Expand All @@ -273,10 +279,13 @@ It is a good habit to always specify these attributes on every image, even when
Here is our Odin Project logo example with height and width tags included:

<p class="codepen" data-height="300" data-default-tab="html,result" data-slug-hash="PogmYGp" data-user="TheOdinProjectExamples" style="height: 300px; box-sizing: border-box; display: flex; align-items: center; justify-content: center; border: 2px solid; margin: 1em 0; padding: 1em;">

<span>See the Pen <a href="https://codepen.io/TheOdinProjectExamples/pen/PogmYGp">
Image Height and Width Attributes</a> by TheOdinProject (<a href="https://codepen.io/TheOdinProjectExamples">@TheOdinProjectExamples</a>)
on <a href="https://codepen.io">CodePen</a>.</span>

</p>

<script async src="https://cpwebassets.codepen.io/assets/embed/ei.js"></script>

Go ahead and update the `odin-links-and-images` project with width and height tags on the dog image.
Expand All @@ -294,7 +303,7 @@ Go ahead and update the `odin-links-and-images` project with width and height ta

### Knowledge check

This section contains questions for you to check your understanding of this lesson on your own. If you’re having trouble answering a question, click it and review the material it links to.
The following questions are an opportunity to reflect on key topics in this lesson. If you can't answer a question, click on it to review the material, but keep in mind you are not expected to memorize or master this knowledge.

- [What element is used to create a link?](#anchor-elements)
- [What is an attribute?](#attribute)
Expand All @@ -308,7 +317,7 @@ This section contains questions for you to check your understanding of this less

### Additional resources

This section contains helpful links to related content. It isnt required, so consider it supplemental.
This section contains helpful links to related content. It isn't required, so consider it supplemental.

- [Interneting is hard's treatment on HTML links and images](https://internetingishard.netlify.app/html-and-css/links-and-images)
- [What happened the day Google decided links including (`/`) were malware](https://www.itpro.co.uk/609724/google-apologises-after-blacklisting-entire-internet)
Expand Down

0 comments on commit 299a037

Please sign in to comment.