Friday 9 January 2015



ATTRIBUTES:

Attributes in HTML are much like the attributes you experience every day. They are the qualities
that describe a person or thing, such as a tall man or a brown dog. Similarly, HTML elements can
be described in ways that web browsers can understand. This section looks at attributes, starting
with the most important one that beats at the heart of the web.What differentiates web documents from standard documents are the links (or hyperlinks) that take you from one web page to another. Look at a link by adding one to the example you just looked at.Links are created using an <a> element. (The a stands for anchor)

You can add a link from this page to Google in a new paragraph at the end of the document. There
is just one new line in this example:
<html>
<head>
<title>Popular Websites: Google</title>
</head>
<body>
<h1>About Google</h1>
<p>Google is best known for its search engine, although Google now offers a number of other  services.</p>
<p>Google's mission is to organize the world's information and make it universally accessible and useful.</p>
<p>Its founders Larry Page and Sergey Brin started Google at Stanford University.</p>
<p><a href="http://www.Google.com/">Click here to visit Google's Web site.</a></p>
</body>
</html>

Inside this new paragraph is the <a> element that creates the link. Between the opening <a> tag and the closing </a> tag is the text that you can click, which says, “Click here to visit Google’s Web site.” If you look closely at the opening tag of the link, it carries something called an attribute. In this case, it’s the href attribute; this is followed by an equal sign and then a pair of quotation marks, which contain the URL for Google’s website. In this case, the href attribute tells you where the link should take you. You look at links in greater detail later, “Links and Navigation,” but for the moment this illustrates the purpose of attributes.
➤➤ Attributes are used to say something about the element that carries them, and they always
appear on the opening tag of the element that carries them. Almost all attributes consist of
two parts: a name and a value. The name is the property of the element that you want to set.
In this example, the <a> element carries an attribute whose name is href, which you can use
to indicate where the link should take you.
➤➤ The value is what you want the value of the property to be. In this example, the value was
the URL of the site that the link should take you to, so the value of the href attribute is
http://www.google.com.
The value of the attribute should always be put in double quotation marks and separated from the
name with the equal sign.

There are several attributes in HTML5 that do not consist of a name/value pair but consist of just
a name. These are called boolean attributes and you will learn more about those in the section
“Attribute Groups.”
Another common attribute on anchors is the title attribute, which gives a plain language description
of the target of the link. You could add one to the example to inform people that Google is a popular
search engine.
<a href="http://www.Google.com"
title="Google.com is the world's most popular search engine">
This illustrates that elements can carry several attributes; although, an element should never have
two attributes of the same name.

No comments:

Post a Comment