You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: curriculum/challenges/english/blocks/lecture-understanding-html-attributes/66f6db08d55022680a3cfbc9.md
+47-11Lines changed: 47 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,15 +5,37 @@ challengeType: 19
5
5
dashedName: what-is-html
6
6
---
7
7
8
-
# --description--
8
+
# --interactive--
9
9
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
11
15
12
16
```html
13
-
<p>Hello</p>
17
+
<h1>Main heading element</h1>
18
+
19
+
<p>I am a paragraph element.</p>
14
20
```
15
21
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:
17
39
18
40
```html
19
41
<p>
@@ -23,7 +45,9 @@ Most elements will have an opening tag and a closing tag. Sometimes those tags a
23
45
</p>
24
46
```
25
47
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:
27
51
28
52
```html
29
53
<img>
@@ -41,23 +65,35 @@ While many code formatters like Prettier, will choose to include the `/` in void
41
65
42
66
In real world development, you will see both forms so it is important to be familiar with both.
43
67
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.
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
51
85
52
86
```html
53
-
<imgsrc="example-cat-img-url"alt="Cat sleeping in the grass">
87
+
<imgsrc="https://cdn.freecodecamp.org/curriculum/cat-photo-app/cats.jpg"alt="Two tabby kittens sleeping together on a couch." />
54
88
```
55
89
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
+
:::
57
91
58
92
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.
59
93
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.
0 commit comments