mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-05-28 18:26:54 +00:00
fix(curriculum): clarify void tag content (#61357)
This commit is contained in:
+17
-10
@@ -1,17 +1,12 @@
|
||||
---
|
||||
id: 66f6db08d55022680a3cfbc9
|
||||
title: What Role Does HTML Play on the Web?
|
||||
challengeType: 11
|
||||
videoId: Me-GFJKL-9E
|
||||
challengeType: 19
|
||||
dashedName: what-is-html
|
||||
---
|
||||
|
||||
# --description--
|
||||
|
||||
Watch the video or read the transcript and answer the questions below.
|
||||
|
||||
# --transcript--
|
||||
|
||||
What Role Does HTML Play on the Web?
|
||||
|
||||
HTML, which stands for Hypertext Markup Language, is a markup language for creating web pages. When you visit a website and see content like paragraphs, headings, links, images, and videos; that's HTML. HTML represents the content and structure of a webpage through the use of elements. Here's an example of a paragraph element:
|
||||
@@ -36,7 +31,19 @@ What distinguishes an opening tag from a closing tag is the forward slash (`/`)
|
||||
<img>
|
||||
```
|
||||
|
||||
Notice that this image element does not have the closing tag and it does not have any content. Void elements cannot have any content and only have a start tag. If you wanted to display an image, you will need to include a couple of attributes inside your image element. An attribute is a special value used to adjust the behavior for an HTML element. Here is an example of an image element with a `src`, or source, attribute:
|
||||
Notice that this image element does not have the closing tag and it does not have any content. Void elements cannot have any content and only have a start tag.
|
||||
|
||||
Sometimes you will see void elements that use a `/` before the `>` like this:
|
||||
|
||||
```html
|
||||
<img />
|
||||
```
|
||||
|
||||
While many code formatters like Prettier, will choose to include the `/` in void elements, the HTML spec states that the presence of the `/` "does not mark the start tag as self-closing but instead is unnecessary and has no effect of any kind".
|
||||
|
||||
In real world development, you will see both forms so it is important to be familiar with both.
|
||||
|
||||
If you wanted to display an image, you will need to include a couple of attributes inside your image element. An attribute is a special value used to adjust the behavior for an HTML element. Here is an example of an image element with a `src`, or source, attribute:
|
||||
|
||||
```html
|
||||
<img src="image location" />
|
||||
@@ -142,7 +149,7 @@ Which of the following is a valid attribute used inside the `img` element?
|
||||
|
||||
### --feedback--
|
||||
|
||||
Review the video starting at the `1:37` timestamp where the `img` element and the appropriate attributes were discussed.
|
||||
Review where the `img` element and the appropriate attributes were discussed.
|
||||
|
||||
---
|
||||
|
||||
@@ -150,7 +157,7 @@ Review the video starting at the `1:37` timestamp where the `img` element and th
|
||||
|
||||
### --feedback--
|
||||
|
||||
Review the video starting at the `1:37` timestamp where the `img` element and the appropriate attributes were discussed.
|
||||
Review where the `img` element and the appropriate attributes were discussed.
|
||||
|
||||
---
|
||||
|
||||
@@ -158,7 +165,7 @@ Review the video starting at the `1:37` timestamp where the `img` element and th
|
||||
|
||||
### --feedback--
|
||||
|
||||
Review the video starting at the `1:37` timestamp where the `img` element and the appropriate attributes were discussed.
|
||||
Review where the `img` element and the appropriate attributes were discussed.
|
||||
|
||||
## --video-solution--
|
||||
|
||||
|
||||
Reference in New Issue
Block a user