-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathimages.html
More file actions
96 lines (76 loc) · 2.43 KB
/
images.html
File metadata and controls
96 lines (76 loc) · 2.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Images in HTML</title>
<link rel="stylesheet" href="css/style.css">
</head>
<body>
<header>
<h1>Images in HTML</h1>
<p>Learn how to add images to your webpage and control how they appear.</p>
</header>
<nav>
<a href="index.html">Home</a>
<a href="text.html">First HTML file</a>
<a href="links.html">Links</a>
<a href="images.html">Images</a>
<a href="lists.html">Lists</a>
<a href="tables.html">Tables</a>
<a href="css.html">CSS</a>
</nav>
<div class="content">
<div class="lesson-box">
<h2>Basic Image</h2>
<p>The <code><img></code> tag displays an image. It needs a <code>src</code> (source) and <code>alt</code> (description):</p>
<pre>
<img src="cat.jpg" alt="A cute cat">
</pre>
<p>The <strong>alt</strong> text is important for accessibility and for when the image can’t load.</p>
</div>
<div class="lesson-box">
<h2>Image Size</h2>
<p>You can control the size of an image using the <code>width</code> or <code>height</code> attributes:</p>
<pre>
<img src="cat.jpg" alt="A cute cat" width="300">
</pre>
<p>Only set one dimension (width <em>or</em> height) to keep the image from stretching.</p>
</div>
<div class="lesson-box">
<h2>Images From the Web</h2>
<p>You can also use images hosted online:</p>
<pre>
<img src="https://example.com/dog.png" alt="A happy dog">
</pre>
<p>This works as long as the image URL is public.</p>
</div>
<div class="lesson-box">
<h2>Organizing Your Images</h2>
<p>It’s a good idea to store your images in a folder like this:</p>
<pre>
project/
index.html
images/
cat.jpg
dog.png
</pre>
<p>Then link to them like this:</p>
<pre>
<img src="images/cat.jpg" alt="A cute cat">
</pre>
</div>
<div class="lesson-box">
<h2>Lesson Checkpoint</h2>
<p>Before moving on, make sure you have:</p>
<ol>
<li>Added at least one image to your project.</li>
<li>Used <code>src</code> and <code>alt</code> correctly.</li>
<li>Experimented with image sizes.</li>
<li>Committed your changes to GitHub.</li>
<li>Viewed your updated site on GitHub Pages.</li>
</ol>
<p>Use the navigation bar to continue to the next lesson.</p>
</div>
</div>
</body>
</html>