Hyperlinks in HTML

Hyperlinks in HTML

Many people associate web pages with hyperlinks, i.e. the ability to navigate from one page to another page. In HTML, hyperlinks (also called ‘anchors’) typically have the following sort of structure:

<a href=”#”;>GO</a> (# = add the link by replacing #)

The text is what the user sees, the value of href is where the link points to.  Points to note include:

  • The ‘GO’ material seen by the user can contain HTML, so can include e.g. images and formatted text
  • The href value used here, i.e.  “Pages/AboutNematrian.pdf” means that the link points to a webpage (or other resource) called “AboutNematrian.pdf” in the directory “Pages” (strictly speaking a subdirectory of the directory in which the source webpage resides, unless it e.g. starts with http:// or https:// or unless the document’s <base> element, if any, defines a different base address to be used by relative uniform resource locators, i.e. ‘URLs’).

The above link renders as:

GO

Groups of hyperlinks can be included in a <nav> element. For example, markup as follows:

<nav>

<a href="Introduction.aspx">Introduction</a> |

<a href="IntroductionSoftware.aspx">Software</a>

</nav>

creates the following output, involving 2 individual hyperlinks:

Introduction | Software

Hits: 10

Comments In HTML

Comments in HTML

It can be helpful to include comments in HTML documents that are not displayed but help readers of the underlying markup text you to understand what the HTML is trying to do. Comments in HTML take the form <!– comment –> and ignore line breaks within the opening and closing tags of the comment element.

For example, markup as follows:

<!-- material explaining how commenting in HTML
       works-->

creates the following output (i.e. nothing):

Hits: 163

Line breaks in HTML

HTML markup largely ignores line breaks within marked up files. Instead, if you want to insert a line breaks you need to insert a <br> tag.

When a line break is inserted the cursor moves down a single line, which is different from the paragraph which ends the paragraph and starts a new one. When you hold Shift and press Enter a line break tag is inserted ( <br /> ) and the text entered after the line break will appear on the next line down.

For example the following markup:


Hello <br> World/>    
   

Output:

Hello 
World

Hits: 10

Introduction to HTML

HTML :  Hypertext Markup Language

 

  1. HTML consists of a series of elements
  2. HTML elements are represented by tags
  3. We can create a static website by HTML only.

 

 <html>

         <head>

         <title></title></head>

         <body>

           hello

         </body>

        </html>
  • <!DOCTYPE html> declaration defines this document
  • <html> element is the root element of an HTML
  • <head> element contains meta information about the document
  • <title> element specifies a title for the document
  • <body> element contains the visible page content

 

An HTML document is made up of tiny little pieces of HTML elements which are called tags. We have opening and closing tags and we can format them like this: <html>

The closing tag follows the same format, only this time, we need to specify a slash after the less than sign, like so: </html>

There are also self closing tags, they are almost identical to the standard closing tags, expect we have the slash before the greater than sign, for example to display an image, we would have to write: <img />

There are of course certain words that should be between the less than and greater than signs, like <html> or <body> each one telling the browser how to render it.

Hits: 13