HTML Attributes
HTML attributes are used to provide additional information about HTML elements. Attributes can be added to almost any HTML element, and are typically added within the opening tag of the element.
Here are some common HTML attributes:
class for adding a class to an element, which can be used for styling or JavaScript manipulation
id for adding a unique identifier to an element, which can be used for targeting with CSS or JavaScript
href for adding a hyperlink to an <a> element
src for adding a source URL to an <img> or <video> element
alt for adding alternate text to an <img> element, which is used for accessibility purposes
style for adding inline CSS styling to an element
Here's an example of using attributes to add a class and ID to an element:
html
<div class="container" id="main-container">
<h1>Page Title</h1>
<p>Some text goes here.</p>
</div>
In this example, the class attribute adds the class "container" to the <div> element, while the id attribute adds the ID "main-container". These attributes can then be used for styling or JavaScript manipulation.
No comments:
Post a Comment