Saturday, February 25, 2012

HTML: Attributes


You can add attributes to elements in the document.

What is an attribute?

Surely you remember that the elements of a structure in HTML documents and tells the browser how you want your website (for example, <br /> tells the browser to create a new line). Some items may contain more information. This additional information are called attributes.

Example 1:


<h2 style="background-color:#ff0000;"> My friendship with HTML </ h2>


Attributes are always placed in the opening tag and the attribute value is placed in quotation marks. We use a semicolon to separate values ??for the attribute style. We'll come back to this later.

What's the catch?

There are many different attributes. First you will learn a style attribute. Using the style attribute, you can add layout to your website. For example, background color:

Example 2:


<html>

<head>
</head>

<body style="background-color:#ff0000;">
</body>

</html>


Shows a red page in the browser - check and see for yourself. For a while we explain exactly how the system works colors.

Note that some tags and attributes using the American spelling for example. color instead of color. It is important for you to be careful using the same spelling that we have in przykładachw course - otherwise, your browser does not understand the code. Also, do not forget to put quotation marks at the end of the attribute value.


As the site changed to red?

In the above example, we asked for the background color code "# ff0000". This is a red color code written using hexadecimal numbers (HEX). Each color has its own number in hexadecimal. Here are some examples:

White: #ffffff
Black: #000000 (zeros)
Red: #FF0000
Blue: #0000FF
Green: #00FF00
Yellow: #FFFF00

Hex color code is written using the character # and six letters. There are over 1000 HEX codes and it is not easy to code responsible for the color.

For convenience this is the map of 216 most frequently used colors:


HTML colours





Example 3:


<body style="background-color: red;">


Just about colors. Let us return to the attributes.

Which elements can have attributes?

Various attributes can be assigned to most elements.

Often you will use the attributes in the tags, such as body, in others less, for example, a year means a new line because there are no parameters to adjust so you do not have attributes.

Just as there are many elements, so there are many attributes. Some attributes are typical only for the data elements while others may be used for many different elements. Also the other way around: some elements may only contain a certain type of attributes while others contain many.

This may sound strange but once you start using the attributes of the time you see their logic, ease of use and capabilities that deliver.

This course will introduce you to the most important attributes.

In what part consists of an element?

In general, the element consists of a start tag, with or without a lot of attributes, content, and a closing tag.

No comments:

Post a Comment