Attributes in Html 1
HTML attributes are special properties or values that give extra information or features to an HTML element. They are included in the opening tag of an HTML element and usually consist of a name and a value separated by an equal sign. The syntax for an attribute consists of the attribute name, followed by an equal sign (=), and then the attribute value enclosed in quotation marks (either single ‘ or double “).
Attributes are important in web development because they let developers modify and improve how HTML elements look and behave.
Point to note: some attributes can change the colour or size of text, while others can add links or buttons to a webpage.
HTML attributes help developers make websites more visually appealing and user-friendly. Some attributes in Html are as follows:
id: Provides a distinct identification to an object, allowing it to be selected for CSS or JavaScript manipulation.
class: Assigns one or more class names to an element, enabling you to apply styles or scripts to groups of elements.
src: Indicates where external resources like images, videos, or scripts are located.
href: Specifies the address where an anchor <a> element leads to.
Get FO-Ria’s stories in your inbox
Join Medium for free to get updates from this writer.
alt: Displays alternative text for images if the images fail to load, and is also helpful for accessibility.
style: This applies inline CSS styles directly to an HTML element.
The general syntax for an HTML attribute is:
<element attribute_name=”attribute_value”>Content</element>. <element>: This is the HTML element or tag that you want to add an attribute to, such as <a>, <img>, <div>, or any other valid HTML element.
attribute_name: This is the name of the attribute you want to define for the element. Attribute names are case-insensitive, but it’s a best practice to use lowercase for readability.
=: The equal sign separates the attribute name from the attribute value.
“attribute_value”: The attribute value is enclosed within double quotes (“”). Depending on the attribute, this value can be a string of text, a URL, a file path, or any other valid value. Although quotes may not always be necessary for some attribute values, it is widely recommended to use them consistently. This practice helps prevent any problems related to certain characters or values that may arise.
For example, to set the src attribute of an <img> element(This is to include an image), you would use the following syntax: <img src=”image.jpg” alt=” Description of the image”> The attribute name src is used here, and the attribute value src is used (path to the image file)).
The opening tag of an element can accommodate various attributes by separating them with spaces. These attributes are essential in web development as they enable developers to manage the appearance, function, and operation of web pages. When HTML elements are embellished with context, metadata, and interactivity, they become more flexible and personalized.
Remember, to practice as much as possible!





