HTML Attributes
* All HTML elements can have attributes
* Attributes provide additional information about an element
* Attributes are always specified in the start tag
* Attributes usually come in name/value pairs like: name="value"
Href Attribute
HTML links are defined with the <a> tag. The link address is specified in the href attribute:
Example
<!DOCTYPE html>
<html>
<body>
<p>HTML links are defined with the a tag. The link address is specified in the href attribute:</p>
<a href="https://www.htmlnotes12.blogspot.com">This is a link</a>
</body>
</html>
Src Attribute
HTML images are defined with the <img> tag.
The filename of the image source is specified in the src attribute:
Example
<!DOCTYPE html>
<html>
<body>
<p>HTML images are defined with the img tag, and the filename of the image source is specified in the src attribute:</p>
<img src="img.jpg" width="500" height="600">
</body>
</html>
Width and height Attributes
HTML images also have width and height attributes, which specifies the width and height of the image:
Example
<!DOCTYPE html>
<html>
<body>
<p>Images in HTML have a set of size attributes, which specifies the width and height of the image:</p>
<img src="img.jpg" width="500" height="600">
</body>
</html>
Style Attribute
The style attribute is used to specify the styling of an element, like color, font, size etc.
Example
<!DOCTYPE html>
<html>
<body>
<p>The style attribute is used to specify the styling of an element, like color:</p>
<p style="color:red">This is a red paragraph.</p>
</body>
</html>
Lang Attribute
The language of the document can be declared in the <html> tag.
The language is declared with the lang attribute.
Declaring a language is important for accessibility applications (screen readers) and search engines:
<!DOCTYPE html>
<html lang="en-US">
<body>
...
</body>
</html>
Comments
Post a Comment