HTML Attributes:
- Attributes are used to give some additional meaning to content encapsulated by its element.
- Attributes consists two parts
- Name
- 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 more number of attributes.
- If an element contains more than one attribute, then those attributes must be separated with a space ( ) character.
- Here bgcolor, background is the attribute with a value to change the background of the webpage.
<html>
<head> </head>
<body bgcolor='red' >
<h1>Welcome<h1>
</body>
</html>
- Change the background color of page using the attribute background.
- We specify the value with either single quotes or double quotes.
- We are setting jpg file as background.
<html>
<head> </head>
<body background='C:\Users\welcome\Desktop\back.jpg'>
<marquee><h1>Welcome<h1></marquee>
</body>
</html>
Note : <marquee> tag is used to scorll the text on the screen from RIGHT to LEFT.
- This code explains how to specify number of attributes of a tag.
- All these attributes need to separate with space symbol
<html>
<head> </head>
<body>
<img src="C:\Users\welcome\Desktop\cute.jpg" width="200" title="Cute" alt="baby picture not availble">
</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 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).