Course Content
Ultimate HTML
Link
The <a>
tag is used to create hyperlinks that allow users to navigate between different web pages. When a user clicks on a link, the browser sends a request to the server for the page associated with the link and displays the response on the screen. The href
attribute helps to specify the URL of the destination page.
index.html
index.css
index.js
Link Attributes
target
By default, the link is opened in the same browser tab. With help of target
attribute we can change this behavior. To open a link in a new tab target="_blank"
is used.
index.html
index.css
index.js
download
It can be used with the HTML <a>
tag to specify that the target resource should be downloaded instead of displayed in the browser. When the download attribute is used, the browser will prompt the user to save the file with the specified filename. For example, we need to create a element with the following functionality. The user clicks on the link, the browser will download the myfile.pdf file from https://example.com/
and prompt the user to save it with the filename myfile.pdf.
index.html
index.css
index.js
href
It is used not only to go to another pages, but also to create links to email addresses, telephone numbers and specific sections.
index.html
index.css
index.js
Also, href
can be used to navigate to specific sections of a web page. To create an anchor tag we put id
attribute (special identifier) to that tag to which we want to scroll the page. href
attribute gets the value starting with #
symbol and id
value. Let's consider the next example.
index.html
index.css
index.js
Button
The <button>
tag in HTML is used to create a clickable button that can trigger an action, such as submitting a form or executing a JavaScript function like open and close pop-up window, toggle a mobile menu. By default, <button>
has attribute type
and its value is submit
. However, most often we need type="button"
.
index.html
index.css
index.js
Note
Link
<a>
tag is used for creating hyperlinks to other web pages, documents, or resources. Button<button>
tag is used for creating interactivity on a web page, triggering an event, or performing an action. We don't mix them.
Can we open a new tab/window with a <button>
tag?
Select the correct answer
Can we use a <button>
tag to submit a form?
Select the correct answer
What is the main difference between the <a>
tag and the <button>
tag?
Select the correct answer
Section 2.
Chapter 5