Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:00,005 --> 00:00:04,000
- Images, can you imagine a web with no images?
2
00:00:04,000 --> 00:00:06,006
Images are everywhere.
3
00:00:06,006 --> 00:00:10,004
The web is a web of text and images.
4
00:00:10,004 --> 00:00:13,008
To put an image on a webpage we use the image element.
5
00:00:13,008 --> 00:00:16,004
It's written as IMG.
6
00:00:16,004 --> 00:00:18,008
And then there are four attributes we want to include
7
00:00:18,008 --> 00:00:20,007
on every image element.
8
00:00:20,007 --> 00:00:24,004
The source attribute, shortened to SRC.
9
00:00:24,004 --> 00:00:27,005
The alt attribute, ALT.
10
00:00:27,005 --> 00:00:30,005
And the width and height attributes.
11
00:00:30,005 --> 00:00:32,006
Every image should have all four.
12
00:00:32,006 --> 00:00:34,006
The source attribute is what tells the browser
13
00:00:34,006 --> 00:00:37,000
which image file to load.
14
00:00:37,000 --> 00:00:45,001
So let me paste the URL to our image into the source.
15
00:00:45,001 --> 00:00:47,004
And you can see, the image is loading.
16
00:00:47,004 --> 00:00:49,007
This URL happens to be an absolute URL
17
00:00:49,007 --> 00:00:52,001
to the CDN on CodePen is storing it's images
18
00:00:52,001 --> 00:00:53,003
for these demos.
19
00:00:53,003 --> 00:00:56,001
It might seem that we're done and that's all we need,
20
00:00:56,001 --> 00:00:57,004
but we're not done yet.
21
00:00:57,004 --> 00:00:59,009
We also need an ALT attribute.
22
00:00:59,009 --> 00:01:02,005
This acts as a substitute for the image
23
00:01:02,005 --> 00:01:04,003
whenever the image can't be seen.
24
00:01:04,003 --> 00:01:05,009
People who are blind, for example,
25
00:01:05,009 --> 00:01:07,005
may use a screen reader that reads
26
00:01:07,005 --> 00:01:09,007
the ALT text aloud to them.
27
00:01:09,007 --> 00:01:12,003
This is what they experience of this image,
28
00:01:12,003 --> 00:01:14,006
so let's make it interesting.
29
00:01:14,006 --> 00:01:20,007
Shiny black dog looking pensive.
30
00:01:20,007 --> 00:01:23,006
We don't need to say a photo of A.
31
00:01:23,006 --> 00:01:24,006
That's overly wordy.
32
00:01:24,006 --> 00:01:27,006
It's understood that this is an image or a photo.
33
00:01:27,006 --> 00:01:29,004
We don't want to use dozens of words
34
00:01:29,004 --> 00:01:31,006
to write everything about this photo,
35
00:01:31,006 --> 00:01:33,006
we want to write about what's most important.
36
00:01:33,006 --> 00:01:35,009
Why are we putting this image on the site?
37
00:01:35,009 --> 00:01:37,005
What matters about it?
38
00:01:37,005 --> 00:01:40,000
Our text can be funny or poetic.
39
00:01:40,000 --> 00:01:41,009
It doesn't have to be dry.
40
00:01:41,009 --> 00:01:44,006
If there's nothing for people to know about the image,
41
00:01:44,006 --> 00:01:47,003
then we can leave the alt text blank.
42
00:01:47,003 --> 00:01:49,008
Here's an example of when that might be the case.
43
00:01:49,008 --> 00:01:50,008
In this header,
44
00:01:50,008 --> 00:01:53,004
the name of the company is wrapped in an h1
45
00:01:53,004 --> 00:01:55,007
and the company logo is an image.
46
00:01:55,007 --> 00:01:57,008
So look at the alt text B,
47
00:01:57,008 --> 00:02:00,001
maybe we could say happy dog.
48
00:02:00,001 --> 00:02:02,000
It is a drawing and a happy dog.
49
00:02:02,000 --> 00:02:04,004
But the name of the company is Happy Dog Daycare,
50
00:02:04,004 --> 00:02:06,006
hearing happy dog, happy dog, daycare
51
00:02:06,006 --> 00:02:09,001
isn't really a better experience.
52
00:02:09,001 --> 00:02:10,007
We'll include the alt attribute.
53
00:02:10,007 --> 00:02:13,002
So it's clear we thought about the alt text,
54
00:02:13,002 --> 00:02:15,001
and then we'll leave it blank.
55
00:02:15,001 --> 00:02:18,004
It'll be skipped over and nothing will be spoken aloud.
56
00:02:18,004 --> 00:02:21,005
If we leave off the alt attribute instead,
57
00:02:21,005 --> 00:02:23,002
there's a chance that the file name
58
00:02:23,002 --> 00:02:25,002
for the image will get read aloud.
59
00:02:25,002 --> 00:02:27,000
So let's not do that.
60
00:02:27,000 --> 00:02:30,005
Next we need to let the browser know how big the image is
61
00:02:30,005 --> 00:02:32,001
in pixels.
62
00:02:32,001 --> 00:02:36,001
This image is 400 pixels wide and 300 pixels tall.
63
00:02:36,001 --> 00:02:38,003
If we open it in something like Photoshop,
64
00:02:38,003 --> 00:02:41,005
we can see that that's actually how big the photo is.
65
00:02:41,005 --> 00:02:43,009
So I'll add that information to the image element
66
00:02:43,009 --> 00:02:46,003
and the width and height attributes.
67
00:02:46,003 --> 00:02:49,002
Now we don't include a unit on these numbers,
68
00:02:49,002 --> 00:02:50,009
we just put the number.
69
00:02:50,009 --> 00:02:54,008
It's understood to mean pixels, actual pixels.
70
00:02:54,008 --> 00:02:56,002
It doesn't matter which comes first,
71
00:02:56,002 --> 00:02:57,002
the height or the width.
72
00:02:57,002 --> 00:02:58,001
In fact,
73
00:02:58,001 --> 00:03:01,004
the order of attributes in an HTML element never matters,
74
00:03:01,004 --> 00:03:04,002
we can put them in whatever order we want.
75
00:03:04,002 --> 00:03:06,002
So why are we doing this?
76
00:03:06,002 --> 00:03:09,002
The image has already loaded and it looks just fine.
77
00:03:09,002 --> 00:03:11,001
It doesn't seem to like typing the width
78
00:03:11,001 --> 00:03:13,001
and height did anything.
79
00:03:13,001 --> 00:03:16,008
Well, once the file is already loaded and on the page,
80
00:03:16,008 --> 00:03:19,008
the width and height attributes don't do anything.
81
00:03:19,008 --> 00:03:21,005
The browser figured out how big
82
00:03:21,005 --> 00:03:24,003
to display the image by downloading it,
83
00:03:24,003 --> 00:03:26,007
looking at the file and its characteristics,
84
00:03:26,007 --> 00:03:29,007
and using that to calculate the layout.
85
00:03:29,007 --> 00:03:31,007
The problem is that if the browser has
86
00:03:31,007 --> 00:03:34,005
to get the size information out of the file,
87
00:03:34,005 --> 00:03:36,005
then it can't calculate this part
88
00:03:36,005 --> 00:03:40,004
of the layout until after the image has downloaded.
89
00:03:40,004 --> 00:03:44,007
If instead we tell the browser how big each image is,
90
00:03:44,007 --> 00:03:46,003
then it knows immediately,
91
00:03:46,003 --> 00:03:49,001
and that gives the browser a split second head start
92
00:03:49,001 --> 00:03:51,002
in calculating the layout.
93
00:03:51,002 --> 00:03:53,007
Have you ever started reading an article on the web
94
00:03:53,007 --> 00:03:56,005
and it keeps jumping around as images load,
95
00:03:56,005 --> 00:03:58,008
moving everything as you're trying to read?
96
00:03:58,008 --> 00:04:02,003
Well, including the width and height attributes
97
00:04:02,003 --> 00:04:04,006
on your images will fix that.
98
00:04:04,006 --> 00:04:09,006
So that's the image element with the source, alt, width
99
00:04:09,006 --> 00:04:12,000
and height attributes.
7141
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.