Labels

Wednesday, October 12, 2011

Style and Link

1.   Style


The HTML <font> Tag Should NOT be used

The <font> tag is deprecated in HTML 4, and removed from HTML5.

Styling HTML with CSS

CSS was introduced together with HTML 4, to provide a better way to style HTML elements.

CSS can be added to HTML in the following ways:

  • in separate style sheet files (CSS files), The preferred way.
  • in the style element in the HTML head section
  • in the style attribute in single HTML elements

2.   HTML Link Syntax


  • Links are specified in HTML using the <a> tag.

The <a> tag can be used in two ways:

To create a link to another document, by using the href attribute

To create a bookmark inside a document, by using the name attribute

  • The HTML code for a link is simple. It looks like this:

< a href="url">Link text</a>

The href attribute specifies the destination of a link.

Tip: The "Link text" doesn't have to be text. It can be an image or any other HTML element.

  • HTML Links - The name attribute to create a bookmark inside an HTML document

The name attribute specifies the name of an anchor.

Note: The upcoming HTML5 standard suggest using the id attribute instead of the name attribute for specifying the name of an anchor. Using the id attribute actually works also for HTML4 in all modern browsers.

Bookmarks are not displayed in any special way. They are invisible to the reader.

Example

A named anchor inside an HTML document:

<a name="tips">Useful Tips Section</a>

Create a link to the "Useful Tips Section" inside the same document:

<a href="#tips">Visit the Useful Tips Section</a>

Or, create a link to the "Useful Tips Section" from another page:

<a href="http://www.w3schools.com/html_links.htm#tips">

 Visit the Useful Tips Section</a>

Basic Notes - Useful Tips

Note: Always add a trailing slash to subfolder references. If you link like this: href="http://www.w3schools.com/html", you will generate two requests to the server, the server will first add a slash to the address, and then create a new request like this: href="http://www.w3schools.com/html/".

 Tip: Named anchors are often used to create "table of contents" at the beginning of a large document. Each chapter within the document is given a named anchor, and links to each of these anchors are put at the top of the document.

No comments:

Post a Comment