HTML TUTORIALS-
HTML id Attribute Tag –
Introduction-
The id attribute in HTML is used to uniquely identify an element within a webpage. Unlike class, which can be used on multiple elements, an id must be unique on a page....
🔹 Purposes of the id Attribute-
1) -Styling specific elements with CSS-
2) -Targeting elements using JavaScript-
3) -Linking to specific sections on the same page (anchor links)-
✅ Example 1: Styling with CSS: -👇
<
!DOCTYPE html>
<html>
<head>
<style>
#main-title {
color: green;
font-size: 24px;
}
</style>
</head>
<body>
<h1 id="main-title">Welcome to My Website www.learntosap.com</h1>
</body>
</html>