- Get link
- X
- Other Apps
Attributes
Attributes are used specify extra properties of the element .Attributes provide additional information about an element or a tag, while also modifying them. Most attributes have a value, the value modifies the attributes.Use of attributes can edit the element 's appearance according to our wish. For example,
The HTML:
<html>
<head>
<title>First Page</title>
</head>
<body>
<p align="center">
This text is aligned to center.
</p>
</body>
</html>
In the above example, the value of "center" indicates that the content within the p element should be aligned to center.
Result:
Note: Attributes are always specified in the start tag, and they appear in name="value" pairs.
Attribute Measurements
As an example, we can modify the horizontal line so it has a width of 50 pixels.
This can be done using the width attribute in HTML code with the <hr /> Tag:
<hr width="50px" />
An element's width can also be defined using percentages:
<hr width="50%" />
The Align Attribute
The align attribute is used to specify how the text is aligned.It tells where the text is to align whether on right,left,center,bottom or top.
In the example below, we have a paragraph that is aligned to the center, and a line that is aligned to the right.
<html>
<head>
<title>First Page</title>
</head>
<body>
<p align="center"> This is a text. <br />
<hr width="30%" align="right" />This is also a text.
</p>
</body>
</html>
Result:
Happy Coding!
Comments
Post a Comment
If you have any doubt, ask here