HTML ATTRIBUTE

What is HTML Attribute

HTML Attribute adds additional information to an element, they are always placed in the opening tag and every element can have a tag. Attributes are usually have a name and a value, for instance name="value"

source(src) Attribute

This attribute is used to embed images in a HTML page. it is denoted as <img src> for images. src attribute specifies the path from which the image is dislayed from.

examples

The <img> element also makes use of width and height attributes to define the size of an imge(in pixcels)

examples

      
                    <!DOCTYPE html>	 
<html>
<head>
<title>Page Title</title>
</head>
<body>
 
<h1>My First Heading</h1>
<p>The golden rule of a paragraph.</p>

<h2>elements  and tags </h2>
<p>whatdo you think an element is? :</p>

<img src="girl.jpg" width="500" height="600">

</body>
</html>
                    

Another attribute images uses is the alt attribute, this is to give an image an alternative text.

  •       
                        <!DOCTYPE html>	 
    <html>
    <head>
    <title>Page Title</title>
    </head>
    <body>
     
    <h1>Alternate attribute</h1>
    <p>It gives default name for images when it is not displaying.</p>
    
    <img src="../images/moonshine.jpg" height="500px" width="600px" alt="nightsky">
    
    </body>
    </html>
                        

    the style attribute

    this attribute is used to add styles to an element such as color, font, text-style etc.

    <p style='color:red;'> the greatest show, by the greatest show man for the greastest people.</p>

  •       
                        <!DOCTYPE html>
    <html lang="en">
        <head></head>
        <body>
            <p style="color:red;">the greatest show, by the 
            greatest show man for the greastest people.</p>
        </body>
    </html>    
    

    More information in HTML STYLE

    lang Attribute

    This attribute is added to the <html> element, it is used to declare the language of the web page, it helps the sreach engine or broswer specify the language.

  •       
                        <!DOCTYPE html>
    <!doctype html>
    <html lang="en">
        <head></head>
        <body>
            <p>en is an abbreviation for english. The language is set to english</p>
        </body>
    </html>    
    

    NOTE: Although HTML does not require lowercase for attributes(lang and LANG) are the same but we advice you make use of lowercase so you dont find it difficult to adjust when using strict documenttype like XHTML.

    single and double quotes

    the values attached to every attribute should be quoted, in a case where the value it self has a single quote, it should then be quoted with double quote and the same goes for the double

          
                        
    <!--correct-->
    <p title="moving forward"> 
    <!--wrong-->
    <p title="moving forward'> 
    <!--correct-->
    <p title='moving forward towards light'> 
        
    

    Dess App

    DessApp is an Integrated E-learning Education, Interactive and User-friendly features, smarter options and redefining your school costs effectively and efficiently.

    View
    1 1