HTML Attributes – HTML Tutorial

This HTML-Attributes post providing complete information about HTML attributes and its elements including what is attribute or property of HTML element and need to of attribute, how to write attributes while defining HTML elements and much more.


 Attribute:

  • Attributes are used to give some additional meaning to content encapsulated by its element.
  • Attributes consists two parts
    1) Name
    2) Value
  • Attribute name and value must be separated with is equal to (=) sign.
  • Attributes must be declared inside the opening tag of an element.
  • A single element can contain 0 or number of attributes.
  • If an element contains more than one attribute, then those attributes must be separated by a space character.
  • Here ‘bgcolor’ is the attribute with a value to change the background of the web page.

 

Code-1 :

<html>
<head> </head>
<body bgcolor=’red’ >
<h1>Welcome<h1>
</body>
</html>

Code-2 :

<html>
<head> </head>
<body background=’……\Picture.jpg’>
<marquee><h1>Welcome<h1></marquee>
</body>
</html>

Note : <marquee> tag is used to scroll the text on the screen from RIGHT to LEFT.

<html>
<head> </head>
<body>
<img src=”……\cutebaby.jpg” width=”200″ title=”Cute” alt=”baby picture not available”>
</body>
</html>

  • Here “src” is the attribute of the <img> tag to display the image on the webpage.
  • Using”src” we can provide the path of the image to display.
  • “title” attribute is to set the title to that image, and that title will appear while we are moving the cursor on that particular image.
  • The “alt” attribute provides alternative information for an image if a user for some reason cannot view it (because of slow connection, an error in the src attribute).

> Learn HTML Anchor tag <

 

Share this