Learn HTML,CSS, Python etc from the foundation

Saturday, December 22, 2018

UNDERSTANDING HTML ATTRIBUTES

No comments :

My heart pounded against my rib when I was called out unprepared to explain HTML attributes some years ago in one of my programming classes as a student. I was disgraced that fateful day. Probably that the reason why I shy away from explaining HTML attributes to people afterward. Nevertheless, HTML attributes are almost indispensable while writing in HTML. They are among the integral part HTML. 
What Are HTML Attributes?
HTML attributes are an important feature in HTML that provides additional information or details about an element or tag, and in the process of providing information, modifies the element. Most attributes in HTML have values, and unsurprisingly, it is these values that modify elements.
 For example, if you set your language as ‘English’ all the words on the web page will be in English.
For example, if you want to set English as the language. Write
<html  lang=’’en’’>
For American English, write
<html  lang=’’en-us’’>
Some of the HTML attributes include alignment attribute, measurement attribute, and so on. Let’s consider measurement and alignment attribute.
1.     1. Measurement Attributes
The unit of measurement in HTML can either be in pixel (px) or percentage (%). For example, if you want to modify a horizontal line with its width as 50px. Then write the following codes.
<hr   width =’’50px’’     />        or
<hr   width =’’50%’’   />

Note: <hr is a code used to represent a horizontal line
2.      
    2. Alignment Attribute
If you want to align sentence, paragraph, image etc. to the center all you  need to do is to write the following codes below
<p align=’’center’’>
          Enter whatever you want to align
</p>
These codes suggest that anything you enter within the <p> tags will be aligned to the center.

FURTHER EXPLANATION ON ALIGN ATTRIBUTES
The functions of align attribute in HTML document are virtually the same thing as the one in MS word.  It defines how text is aligned or positioned on a web page.
Let’s consider the example below for further clarification. So get your laptop or computer ready. Open your text editor and enter the codes below:
<html>
      <head>
            <title>HTML Tutorial</title>
        </head>
        <body>
                 <p     align=’’center’’>I am a programmer<br    />
               <hr   width=’’10%’’        align=’’right’’       /> and coding gives me joy.
               </p>
       </body>
</html>


WRAPPING UP

Kindly note that some of the things stipulated above are not applicable in HTML5. For instance, <p> tags are not supported in HTML 5. Don’t panic if you don’t understand what I meant by the above statement, I will make it clearer when we get to HTML5 lesson. Our next lesson will be on how to add image and link in HTML document.

No comments :

Post a Comment