Attribute
Attributes usually appear as name/value pairs (name=”value”). Attributes appear in web page code within a start tag. These provide additional details about the element and also influence the way these elements are displayed on a web page. ‘class’, ‘src’, ‘alt’, etc. are some common attributes. The ‘src’ attribute is used to specify the source of media, ‘class’ to apply CSS styles and ‘alt’ to provide alternate text for an image, if the image is not displayed. Some attributes can be applied to all HTML elements and these are called global attributes. Examples of how to write attributes are given below;
Inorder to display an alternative text to an image that cannot be displayed, we use the alt attribute and src to specify the image source.
<img src=”image.jpg” alt=”Picture of a tree”>
Placeholder attribute is used to display a temporary text in a field, displayed until the user enters a value. It is used on <input> or <textarea> element.
<input type=”text” name=”first name” placeholder=”Enter your first name”>