Skip to content

Commit f14934c

Browse files
authored
feat(curriculum): Add interactive examples to intro HTML lesson (freeCodeCamp#62627)
1 parent 4afd65e commit f14934c

File tree

1 file changed

+47
-11
lines changed

1 file changed

+47
-11
lines changed

curriculum/challenges/english/blocks/lecture-understanding-html-attributes/66f6db08d55022680a3cfbc9.md

Lines changed: 47 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,37 @@ challengeType: 19
55
dashedName: what-is-html
66
---
77

8-
# --description--
8+
# --interactive--
99

10-
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:
10+
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.
11+
12+
Here is a small example using HTML elements. Try editing some of the text in the editor and see the changes update in the preview window.
13+
14+
:::interactive_editor
1115

1216
```html
13-
<p>Hello</p>
17+
<h1>Main heading element</h1>
18+
19+
<p>I am a paragraph element.</p>
1420
```
1521

16-
Most elements will have an opening tag and a closing tag. Sometimes those tags are referred to as start and end tags. In between those two tags, you will have the content. This content can be text or other HTML elements. Both opening and closing tags start with a left angle bracket (`<`), and end with a right angle bracket (`>`), with the tag name placed between these angle brackets. While HTML tag names are case-insensitive, it is a widely accepted convention and best practice to write them in lowercase. Here is a closer look at just the opening and closing paragraph tags:
22+
:::
23+
24+
HTML represents the content and structure of a webpage through the use of elements. Most elements will have an opening tag and a closing tag. Sometimes those tags are referred to as start and end tags. In between those two tags, you will have the content. This content can be text or other HTML elements.
25+
26+
Here is another example of a paragraph element. Change the text in the editor to say `I love coding!` and see the results in the preview window.
27+
28+
:::interactive_editor
29+
30+
```html
31+
<p>I am a paragraph element.</p>
32+
```
33+
34+
:::
35+
36+
Both opening and closing tags start with a left angle bracket (`<`), and end with a right angle bracket (`>`), with the tag name placed between these angle brackets. While HTML tag names are case-insensitive, it is a widely accepted convention and best practice to write them in lowercase.
37+
38+
Here is a closer look at just the opening and closing paragraph tags:
1739

1840
```html
1941
<p>
@@ -23,7 +45,9 @@ Most elements will have an opening tag and a closing tag. Sometimes those tags a
2345
</p>
2446
```
2547

26-
What distinguishes an opening tag from a closing tag is the forward slash (`/`) placed immediately after the left angle bracket in a closing tag. Some HTML elements do not have a closing tag. These are known as void elements. Here is an example of an image element which is a void element:
48+
What distinguishes an opening tag from a closing tag is the forward slash (`/`) placed immediately after the left angle bracket in a closing tag. Some HTML elements do not have a closing tag. These are known as void elements.
49+
50+
Here is an example of an image element which is a void element:
2751

2852
```html
2953
<img>
@@ -41,23 +65,35 @@ While many code formatters like Prettier, will choose to include the `/` in void
4165

4266
In real world development, you will see both forms so it is important to be familiar with both.
4367

44-
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:
68+
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.
69+
70+
Here is an example of an image element with a `src` attribute. Update the value of the `src` attribute to `"https://cdn.freecodecamp.org/curriculum/cat-photo-app/cats.jpg"` and you will see the image change to two cats peacefully sleeping.
71+
72+
:::interactive_editor
4573

4674
```html
47-
<img src="image location" />
75+
<img src="https://cdn.freecodecamp.org/curriculum/cat-photo-app/running-cats.jpg" />
4876
```
4977

50-
The `src` attribute is used to specify the location for that image. For image elements, it's good practice to include another attribute called the `alt` attribute. Here's an example of an image element with the `src` and `alt` attributes:
78+
:::
79+
80+
The `src` attribute is used to specify the location for that image. For image elements, it's good practice to include another attribute called the `alt` attribute. The `alt` attribute is used to provide short, descriptive text for the images.
81+
82+
Here's an example of an image element with the `src` and `alt` attributes. Try breaking the image by updating the `src` value to `"https://.freecodecamp.org/curriculum/cat-photo-app/cats.jpg"`. You will see the image disappear and only the `alt` text show.
83+
84+
:::interactive_editor
5185

5286
```html
53-
<img src="example-cat-img-url" alt="Cat sleeping in the grass">
87+
<img src="https://cdn.freecodecamp.org/curriculum/cat-photo-app/cats.jpg" alt="Two tabby kittens sleeping together on a couch." />
5488
```
5589

56-
The `alt` attribute is used to provide short, descriptive text for the images. In this case, the descriptive text is a "Cat sleeping in the grass".
90+
:::
5791

5892
So, you might be wondering if HTML by itself is enough to build a website. Well, the answer is: it depends. If you're building a small practice project that only displays text and images, HTML alone might be sufficient. However, if you're creating a modern professional website, you will need to have HTML, CSS, and JavaScript.
5993

60-
HTML is for the content and structure. CSS is for styling. JavaScript is for adding interactivity to your web pages. A good analogy for this is to compare HTML, CSS, and JavaScript with a complete building. HTML represents the blocks, concrete, and irons that make up the walls. It's the foundation that makes the building strong. CSS represents the interior and exterior design that makes the house look beautiful. JavaScript represents the electrical and water system that ensures uninterrupted access to water and electricity.
94+
HTML is for the content and structure. CSS is for styling. JavaScript is for adding interactivity to your web pages. A good analogy for this is to compare HTML, CSS, and JavaScript with a complete building.
95+
96+
HTML represents the blocks, concrete, and irons that make up the walls. It's the foundation that makes the building strong. CSS represents the interior and exterior design that makes the house look beautiful. JavaScript represents the electrical and water system that ensures uninterrupted access to water and electricity.
6197

6298
# --questions--
6399

0 commit comments

Comments
 (0)