-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathf8.html
192 lines (172 loc) · 8.14 KB
/
f8.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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
<!DOCTYPE html>
<html lang="en-US">
<head>
<title>HTML - Text Links</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="clearer"></div>
<h2>HTML - Text Links</h2>
<p>A webpage can contain various links that take you directly to other pages and even specific parts of a given page. These links are known as hyperlinks.</p>
<p>Hyperlinks allow visitors to navigate between Web sites by clicking on words, phrases, and images. Thus you can create hyperlinks using text or images available on a webpage.</p>
<p><b>Note</b> − I recommend you to go through a short tutorial on <a href="https://en.wikipedia.org/wiki/URL">Understanding URL</a></p>
<h2>Linking Documents</h2>
<p>A link is specified using HTML tag <a>. This tag is called <b>anchor tag</b> and anything between the opening <a> tag and the closing </a> tag becomes part of the link and a user can click that part to reach to the linked document. Following is the simple syntax to use <a> tag.</p>
<pre style="background-color:azure; class="result notranslate">
<a href = "Document URL" ... attributes-list>Link Text</a>
</pre>
<h3>Example</h3>
<p>Let's try following example which links <a href="home.html" target="_blank">StudyWelfare Tutorial</a>at your page −</p>
<pre style="background-color:azure; class="prettyprint notranslate">
<!DOCTYPE html>
<html>
<head>
<title>Hyperlink Example</title>
</head>
<body>
<p>Click following link</p>
<a href = "home.html" target = "_self">StudyWelfare Tutorials</a>
</body>
</html>
</pre>
</div>
<a target="_blank" href="f8-1.html" class="w3-btn w3-margin-bottom"><button style="background-color:rgb(115, 126, 226);">Try it Yourself</button> »</a>
</div>
<h2>The target Attribute</h2>
<p>We have used <b>target</b> attribute in our previous example. This attribute is used to specify the location where linked document is opened. Following are the possible options −</p>
<table class="table table-bordered">
<tr>
<th>Sr.No</th>
<th>Option & Description</th>
</tr>
<tr>
<td class="ts">1</td>
<td>
<p><b>_blank</b></p>
<p>Opens the linked document in a new window or tab.</p>
</td>
</tr>
<tr>
<td class="ts">2</td>
<td>
<p><b>_self</b></p>
<p>Opens the linked document in the same frame.</p>
</td>
</tr>
<tr>
<td class="ts">3</td>
<td>
<p><b>_parent</b></p>
<p>Opens the linked document in the parent frame.</p>
</td>
</tr>
<tr>
<td class="ts">4</td>
<td>
<p><b>_top</b></p>
<p>Opens the linked document in the full body of the window.</p>
</td>
</tr>
<tr>
<td class="ts">5</td>
<td>
<p><b>targetframe</b></p>
<p>Opens the linked document in a named <i>targetframe</i>.</p>
</td>
</tr>
</table>
<h3>Example</h3>
<p>Try following example to understand basic difference in few options given for target attribute.</p>
<pre style="background-color:azure; class="prettyprint notranslate">
<!DOCTYPE html>
<html>
<head>
<title>Hyperlink Example</title>
<base href = "home.html">
</head>
<body>
<p>Click any of the following links</p>
<a href = "home.html" target = "_blank">Opens in New</a> |
<a href = "home.html" target = "_self">Opens in Self</a> |
<a href = "home.html" target = "_parent">Opens in Parent</a> |
<a href = "home.html" target = "_top">Opens in Body</a>
</body>
</html>
</pre>
</div>
<a target="_blank" href="f8-2.html" class="w3-btn w3-margin-bottom"><button style="background-color:rgb(115, 126, 226);">Try it Yourself</button> »</a>
</div>
<h2>Use of Base Path</h2>
<p>When you link HTML documents related to the same website, it is not required to give a complete URL for every link. You can get rid of it if you use <b><base></b> tag in your HTML document header. This tag is used to give a base path for all the links. So your browser will concatenate given relative path to this base path and will make a complete URL.</p>
<h3>Example</h3>
<p>Following example makes use of <base> tag to specify base URL and later we can use relative path to all the links instead of giving complete URL for every link.</p>
<pre style="background-color:azure; class="prettyprint notranslate">
<!DOCTYPE html>
<html>
<head>
<title>Hyperlink Example</title>
<base href = "home.html">
</head>
<body>
<p>Click following link</p>
<a href = "home.html" target = "_blank">HTML Tutorial</a>
</body>
</html>
</pre>
</div>
<a target="_blank" href="f8-3.html" class="w3-btn w3-margin-bottom"><button style="background-color:rgb(115, 126, 226);">Try it Yourself</button> »</a>
</div>
<h2>Linking to a Page Section</h2>
<p>You can create a link to a particular section of a given webpage by using <b>name</b> attribute. This is a two-step process.</p>
<blockquote><p><b>Note</b> − The <i>name</i> attribute deprecated in HTML5. Do not use this attribute. Use <i>id</i> and <i>title</i> attribute instead.</p></blockquote>
<p>First create a link to the place where you want to reach with-in a webpage and name it using <a...> tag as follows −</p>
<pre style="background-color:azure; class="result notranslate">
<h1>HTML Text Links <a name = "top"></a></h1>
</pre>
<p>Second step is to create a hyperlink to link the document and place where you want to reach −</p>
<pre style="background-color:azure; class="result notranslate">
<a href = "/html/html_text_links.htm#top">Go to the Top</a>
</pre>
<p>This will produce following link, where you can click on the link generated <b>Go to the Top</b> to reach to the top of the HTML Text Link tutorial.</p>
<pre style="background-color:azure; class="result notranslate">
<a href="/html/html_text_links.htm#top">Go to the Top</a>
</pre>
<h2>Setting Link Colors</h2>
<p>You can set colors of your links, active links and visited links using <b>link</b>, <b>alink</b> and <b>vlink</b> attributes of <body> tag.</p>
<h3>Example</h3>
<p>Save the following in test.htm and open it in any web browser to see how <b>link</b>, <b>alink</b> and <b>vlink</b> attributes work.</p>
<pre style="background-color:azure; class="prettyprint notranslate">
<!DOCTYPE html>
<html>
<head>
<title>Hyperlink Example</title>
<base href = "home.html">
</head>
<body alink = "#54A250" link = "#040404" vlink = "#F40633">
<p>Click following link</p>
<a href = "home.html" target = "_blank" >HTML Tutorial</a>
</body>
</html>
</pre>
</div>
<a target="_blank" href="f8-4.html" class="w3-btn w3-margin-bottom"><button style="background-color:rgb(115, 126, 226);">Try it Yourself</button> »</a>
</div>
<h2>Download Links</h2>
<p>You can create text link to make your PDF, or DOC or ZIP files downloadable. This is very simple; you just need to give complete URL of the downloadable file as follows −</p>
<pre style="background-color:azure; class="prettyprint notranslate">
<!DOCTYPE html>
<html>
<head>
<title>Hyperlink Example</title>
</head>
<body>
<a href = "home.html">Download PDF File</a>
</body>
</html>
</pre>
</div>
<a target="_blank" href="f8-5.html" class="w3-btn w3-margin-bottom"><button style="background-color:rgb(115, 126, 226);">Try it Yourself</button> »</a>
</div>
<h2>File Download Dialog Box</h2>
<p>Sometimes it is desired that you want to give an option where a user will click a link and it will pop up a "File Download" box to the user instead of displaying actual content. This is very easy and can be achieved using an HTTP header in your HTTP response.</p>
</body>
</html>