HTML-Links und Navigation

Links are a fundamental element of HTML programming and play a crucial role in navigating between different web pages and resources. In this blog post, we will take a closer look at HTML links and how they are used for navigation.

 

 

 

 

 

Creating Hyperlinks:

 

HTML (Hypertext Markup Language) is the basic coding language used to create websites. To create a hyperlink, you need HTML tags. The most important tag is the "a" tag, which represents the link itself. Here is an example of the HTML code for creating a simple text link:

 

< a href="/[http://www.examplewebsite.com](http://www.examplewebsite.com)" >Visit our example website< /a >

 

The text "Visit our example website" is displayed as a clickable link. When a user clicks on it, they are redirected to the specified website.

 

 

To create a link to an email address, use the "mailto" command in the href attribute. Here is an example:

 

< a href="/mailto\:info\@examplewebsite.com" >Contact us by email< /a >

 

When a user clicks on this link, their email program opens with the specified email address as the recipient.

 

 

To create a link to a specific section on the same page, the ID of the section is used. Here is an example:

 

< a href="#section" >Jump to section< /a >

 

In this example, "section" is the ID of the section on the same page. When the user clicks on the link, the page automatically scrolls to the specified section.

 

 

It is also possible to create hyperlinks within images or other elements. The HTML code is similar, but instead of text, you use the "img" tag or the corresponding tag for the element you want to use:

 

< a href="/[http://www.examplewebsite.com](http://www.examplewebsite.com)" > < img src="/image.jpg" alt="Visit our example website" > < /a >

 

Here, the image "image.jpg" is used as a clickable link. When the user clicks on it, they are redirected to the specified website.

 

 

alt attribute

 

 

Linking Within a Web Page:

 

To create a link within a web page, we need two basic HTML elements: the "a" tag and the "href" attribute. You have already learned about the "a" tag. The "href" attribute stands for "Hypertext Reference" and is used to specify the reference to the target page.

 

 

To create a link, we use the following syntax:

 

< a href="/targetpage.html" >Link text< /a >

 

Here, "targetpage.html" is replaced by the file name or URL of the target page. The "Link text" can be anything that is displayed and that the user can click to navigate to the target page.

 

It is important to note that HTML files are usually organized hierarchically in directories or folders. Therefore, we need to specify the path to the target page correctly. If the target page is in the same directory as the current page, we can simply use the file name. However, if the target page is located in a different directory, we need to adjust the path. Here are some examples:

 

- If the target page is located in the parent directory: < a href="/../targetpage.html" >Link text< /a >

- If the target page is located in a subdirectory named "Subdirectory": < a href="/Subdirectory/targetpage.html" >Link text< /a >

- If the target page is located in a subdirectory within another subdirectory: < a href="/Subdirectory1/Subdirectory2/targetpage.html" >Link text< /a >

 

 

It is also possible to create external links that point to another website or an external resource. To do this, we can simply specify the complete URL:

 

< a href="/[https://www.example.com](https://www.example.com)" >Link text< /a >

 

In addition to the "href" attribute, there are other attributes that we can use to customize the behavior of the link. One example is the "target" attribute, which allows us to specify whether the link should be opened in a new browser window:

 

< a href="/targetpage.html" target="\_blank" >Link text< /a >

 

In this example, the target page is opened in a new browser window.

 

 

Our Internet Agency Munich, Econcess, places great importance on engaging design in order to appeal to a wide range of customers. If you are interested in a website for your company, please feel free to contact us. We specialize in customized solutions and provide professional support in the implementation of your digital projects.