Core Attributes of HTML

These are a few important core attributes of HTML:

  • Title
  • Id
  • Style
  • Class

1. Title:

It specifies additional information about an element. This information is often displayed as a tooltip text when the mouse moves over the element.

The aim of Title attributes depends upon the element that carries it.

For example,

<!DOCTYPE html>
<html>
<head>
<title> title Attribute </title>
</head>
<body>
<h3 title = "Hello Title Example Test">Going to college after long time</h3>
</body>
</html>

Output

Going to college after long time

2. Id

Id attribute is used to uniquely identify the element in the HTML page. This is used by JavaScript and CSS to do a particular task for a unique element.  Sometimes in the HTML page, the same element has been used multiple times, with the help of these attributes we can identify element and its content.

For example:

<!DOCTYPE html>
<html>

<head>
  <style>
  #geeks {
    color: blue;
  }
  </style>
</head>

<body>
  <h2>Welcome to Codespeedy</h2>
  <h1 id="code">Hi Coders!</h1> </body>

</html>

3.style

A style attribute in HTML is a shortcut method of adding a CSS style directly to an element, rather than defining the element as a class or by ID.

It specifies an inline style for an element.

For example:

<!DOCTYPE html>
<html>
<head>
<title>The style Attribute, one of core attributes</title>
</head>
<body>
<p style = "font-family:arial; color:#FF0000;">This is style Attributes text , it is blue color...</p>
</body>
</html>

output

This is style Attributes text, it is blue color…

4. class

This attribute is used to refer to a class name in a style sheet. It can also be used by CSS and JavaScript to do special tasks for elements with the specified class name.

For example:

class = "className101 className102 className103"

 

Leave a Reply

Your email address will not be published.