Home » HTML » HTML: Learn to Code Core Attributes

HTML: Learn to Code Core Attributes

Besides the attribute you've learned so far, HTML provides some core attributes that you can use with most elements. In this tutorial, you will learn how to code the core attributes of HTML.

HTML Core Attributes

Attribute Description
id Specifies a unique identifier for an element that can be referred to by CSS.
class Specifies one or more class names that can be referred to by CSS, and the same name can be used for more than one element. To code more than one class name, separate the class name with spaces.
title Specifies additional information about an element. For some elements, the title appears in a tooltip when the user hovers the mouse over the element.
lang Identifies the language that the content of the element is written in.

Notes on HTML Core Attributes

  • Always code the lang attribute on the HTML element to identify the language for the page.
  • The core attributes can be coded for most HTML elements.
  • ID and Class names are case sensitive, should start with a letter, and can include letters, numbers, underscores, hyphens, colons, and periods.
  • The lang attribute is typically used to assist screen readers in reading content correctly and in providing for searches that are restricted by language.


<html lang="en">

        .cls_p {
            background-color: #ffaac8
        #fname {
            color: red;

    <h1>HTML Core Attributes</h1>
    <h3>Attribute class Example</h3>
    <p class="cls_p">This is the paragraph specified by class.</p>
    <h3>Attribute id and Title Example</h3>
    <form action="submit.php" method="post">
        <p>Please enter your first name.</p>
        <p>First Name:
            <input type="text" name="fname" id="fname" title="Enter first name.">
            <input type="submit" value="Submit">



The output would be as shown in the featured image of this article.

See also: