Attributes

Attributes

In some situations, elements take attributes that defines the properties and some information about the elements. Attributes can also be considered as variables that can be assigned a different value. These values define the specification of the elements.

ALIGN

Let’s understand this concept by demonstrating an example:

<h1 ALIGN = “ centre”> Heading </h1>

The above example contains an attribute ALIGN having a value centre applying on the heading 1. This is very simple as we do in a word document, we pass commands to HTML document to centre justify the heading 1. It should be noted here that attributes are always appear in the start tag of the element.

SRC

SRC is also an attribute that is used in the IMG element. IMG is used to include images to the HTML document. SRC is basically a source file for the image. SRC is also a URL that is a uniform resource locator that points to the image file. Consider the following example to understand SRC:

<IMG SRC = “untitled.png” >

Just like an element name, the attribute name is also case insensitive. That means that it does not have any affect that we use an upper case attribute or a lower case attribute. But it does have an effect on the value that is assigned to the SRC. But this case sensitivity can be resolved by enclosing the string within inverted commas or quotation marks.

Horizontal Rules

This is another element in HTML document which is used to draw a horizontal dividing line across the page. “Horizontal rules” is very useful in case when the user wants to make or divide sections. This element is an empty element that is we do not write anything because it does not affect the body of the text. The short form for this element is HR.

In HTML document whitespaces, tabs and blank lines are invalid. The white spaces, tabs and blank lines do not affect the body of the document or its justification or indentation. Only the markup tags affect the document of HTML.

HREF

In other words attributes can also be defined as the quantities that are used to specify the properties for a particular element. You may know an element A that means hypertext anchor. This element takes attribute HREF. This attribute is used to specify the target of the link of the hypertext. In HTML document there are attributes that have been assigned values. HREF is one of these attributes that is used to assign a URL (uniform resource locator) for the hypertext link to point the targeted document. For example:

<A HREF = “facebook.com”> Facebook </A>

In the above example HREF is assigned a URL or a link facebook.com. This link has been given a name Facebook, it can be different as you want it to be. It we write this in our notepad and save the document with html extension the following will appear:

href

The name that is given to the hyperlink is Facebook and it appears on the screen but not the link itself. By clicking on the link the browser will take us to the pointed or targeted document. Now we have facebook opened.

ALT

This attribute represents an alternative text for the images in HTML document. It is used with the IMG element.

Attribute Values

As the elements and attributes names are case insensitive, the values that have been assigned to the attributes are case sensitive. A URL have both filename information and the directory information. In file and directories names, some computers allow to use both upper and lower case. To do this the attribute value or the argument should be written in inverted commas.