Quick Contact

    HTML Attributes

    What are Attributes

    Attributes define extra features or qualities of a component, such as an image’s width and height. Attributes are always supplied in the start tag (or opening tag) and normally consists of name/value pairs like name=”value”. Quotes should always be used around attribute values.

    Furthermore, some properties are necessary for specific items. An tag, for example, must include src and alt properties. Let’s look at some instances of how the characteristics are used:

    Syntax

    < element attribute_name=”value”>content< /element>

    In HTML5, there are numerous attributes that do not consist of name/value pairs but only of the name. These are known as Boolean attributes. Some popular Boolean properties are checked, disabled, readonly, necessary, and so on.

    Example

    < !DOCTYPE html>
    < html lang="en">
    < head>
    < title>Using HTML Boolean Attributes< /title>
    < /head>
    < body>
    < p>< input type="Email" required>< /p>
    < p>< input type="submit" value="Submit" disabled>< /p>
    < p>< input type="checkbox" checked>< /p>
    < p>< input type="text" value="Read only text" readonly>< /p>
    < /body>
    < /html>
    

    Note:

    With the exception of the id and class attributes, attribute values are normally case-insensitive. In its standard, the World Wide Web Consortium (W3C) supports lowercase for attribute values.

    General Purpose Attributes

    On the majority of HTML elements, you may utilize attributes such as id, title, class, style, and so on. The next section explains how to use them.

    The id Attribute

    The id property is used to provide a document element a unique name or identity. This makes selecting the element using CSS or JavaScript easy.

    Example

    < !DOCTYPE html>
    < html lang="en">
    < head>
    < title>HTML id Attribute< /title>
    < style>
            #firstName{
    border: 1px solid blue;
            }
            #container{
    background: #ccc;
            }
            #infoText{
    color: red;
            }
    < /style>
    < /head>
    < body>
    < p>< input type="text" id="firstName">< /p>
    < div id="container">Heading< /div>
    < p id="infoText">Paragraph.< /p>
    < /body>
    < /html>
    

    Note:

    An element’s id must be unique inside a single document. No two elements in the same page can have the same id, and each element can only have one.

    The class Attribute

    The class attribute, like the id attribute, is used to identify items. But unlike id, the class property does not have to be unique in the document.

    The title Attribute

    To give advisory language about an element or its content, the title property is utilized.

    The style Attribute

    You may use the style property to set CSS stylistic rules such as colour, font, border, and so on right within the element.

    Copyright 1999- Ducat Creative, All rights reserved.

    Anda bisa mendapatkan server slot online resmi dan terpercaya tentu saja di sini. Sebagai salah satu provider yang menyediakan banyak pilihan permainan.