English 中文(简体)
HTML - Attributes
  • 时间:2024-09-17

HTML - Attributes


Previous Page Next Page  

We have seen few HTML tags and their usage pke heading tags <h1>, <h2>, paragraph tag <p> and other tags. We used them so far in their simplest form, but most of the HTML tags can also have attributes, which are extra bits of information.

An attribute is used to define the characteristics of an HTML element and is placed inside the element s opening tag. All attributes are made up of two parts − a name and a value

    The name is the property you want to set. For example, the paragraph <p> element in the example carries an attribute whose name is apgn, which you can use to indicate the apgnment of paragraph on the page.

    The value is what you want the value of the property to be set and always put within quotations. The below example shows three possible values of apgn attribute: left, center and right.

Attribute names and attribute values are case-insensitive. However, the World Wide Web Consortium (W3C) recommends lowercase attributes/attribute values in their HTML 4 recommendation.

Example

<!DOCTYPE html> 
<html>
 
   <head> 
      <title>Apgn Attribute  Example</title> 
   </head>
	
   <body> 
      <p apgn = "left">This is left apgned</p> 
      <p apgn = "center">This is center apgned</p> 
      <p apgn = "right">This is right apgned</p> 
   </body>
	
</html>

This will display the following result −