-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathf5.html
131 lines (110 loc) · 5.22 KB
/
f5.html
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
<!DOCTYPE html>
<html lang="en-US">
<head>
<title>HTML - Images</title>
<link rel="shortcut icon" sizes="200*200" type="image/x-icon" href="logo1.jpg"></head>
<body style="background-color: aliceblue;color:rgb(90, 46, 194)">
<div class="mui-col-md-6 tutorial-content">
<h1>HTML - Images</h1>
<div class="clearer"></div>
<p>Images are very important to beautify as well as to depict many complex concepts in simple way on your web page. This tutorial will take you through simple steps to use images in your web pages.</p>
<h2>Insert Image</h2>
<p>You can insert any image in your web page by using <b><img></b> tag. Following is the simple syntax to use this tag.</p>
<pre style="background-color:azure; class="result notranslate">
<img src = "Image URL" ... attributes-list/>
</pre>
<p>The <img> tag is an empty tag, which means that, it can contain only list of attributes and it has no closing tag.</p>
<h3>Example</h3>
<p>To try following example, let's keep our HTML file test.htm and image file test.png in the same directory −</p>
<pre style="background-color:azure; class="prettyprint notranslate">
<!DOCTYPE html>
<html>
<head>
<title>Using Image in Webpage</title>
</head>
<body>
<p>Simple Image Insert</p>
<img src = "/html/images/test.png" alt = "Test Image" />
</body>
</html>
</pre>
</div>
<a target="_blank" href="f5-1.html" class="w3-btn w3-margin-bottom"><button style="background-color:rgb(115, 126, 226);">Try it Yourself</button> »</a>
</div>
<p>You can use PNG, JPEG or GIF image file based on your comfort but make sure you specify correct image file name in <b>src</b> attribute. Image name is always case sensitive.</p>
<p>The <b>alt</b> attribute is a mandatory attribute which specifies an alternate text for an image, if the image cannot be displayed.</p>
<h2>Set Image Location</h2>
<p>Usually we keep all the images in a separate directory. So let's keep HTML file test.htm in our home directory and create a subdirectory <b>images</b> inside the home directory where we will keep our image test.png.</p>
<h3>Example</h3>
<p>Assuming our image location is "image/test.png", try the following example −</p>
<pre style="background-color:azure; class="prettyprint notranslate">
<!DOCTYPE html>
<html>
<head>
<title>Using Image in Webpage</title>
</head>
<body>
<p>Simple Image Insert</p>
<img src = "/html/images/test.png" alt = "Test Image" />
</body>
</html>
</pre>
</div>
<a target="_blank" href="f5-2.html" class="w3-btn w3-margin-bottom"><button style="background-color:rgb(115, 126, 226);">Try it Yourself</button> »</a>
</div>
<h2>Set Image Width/Height</h2>
<p>You can set image width and height based on your requirement using <b>width</b> and <b>height</b> attributes. You can specify width and height of the image in terms of either pixels or percentage of its actual size.</p>
<h3>Example</h3>
<pre style="background-color:azure; class="prettyprint notranslate">
<!DOCTYPE html>
<html>
<head>
<title>Set Image Width and Height</title>
</head>
<body>
<p>Setting image width and height</p>
<img src = "/html/images/test.png" alt = "Test Image" width = "150" height = "100"/>
</body>
</html>
</pre>
</div>
<a target="_blank" href="f5-3.html" class="w3-btn w3-margin-bottom"><button style="background-color:rgb(115, 126, 226);">Try it Yourself</button> »</a>
</div>
<h2>Set Image Border</h2>
<p>By default, image will have a border around it, you can specify border thickness in terms of pixels using border attribute. A thickness of 0 means, no border around the picture.</p>
<h3>Example</h3>
<pre style="background-color:azure; class="prettyprint notranslate">
<!DOCTYPE html>
<html>
<head>
<title>Set Image Border</title>
</head>
<body>
<p>Setting image Border</p>
<img src = "/html/images/test.png" alt = "Test Image" border = "3"/>
</body>
</html>
</pre>
</div>
<a target="_blank" href="f5-4.html" class="w3-btn w3-margin-bottom"><button style="background-color:rgb(115, 126, 226);">Try it Yourself</button> »</a>
</div>
<h2>Set Image Alignment</h2>
<p>By default, image will align at the left side of the page, but you can use <b>align</b> attribute to set it in the center or right.</p>
<h3>Example</h3>
<pre style="background-color:azure; class="prettyprint notranslate">
<!DOCTYPE html>
<html>
<head>
<title>Set Image Alignment</title>
</head>
<body>
<p>Setting image Alignment</p>
<img src = "/html/images/test.png" alt = "Test Image" border = "3" align = "right"/>
</body>
</html>
</pre>
</div>
<a target="_blank" href="f5-5.html" class="w3-btn w3-margin-bottom"><button style="background-color:rgb(115, 126, 226);">Try it Yourself</button> »</a>
</div>
</body>
</html>