The New Attributes

HTML 5 has embedded new attributes that define the characteristics of the HTML elements. You can define an attribute in the HTML element and then provide its value in double quotes. Below given lists all the new attributes of HTML 5:

Attribute

Description

contenteditable

Allows a user to edit content in the document. It accepts either true or false as the Boolean value.

contextmenu

Defines the context menu for an element. It is defined by providing the menu_id as value.

data-yourvalue

Provides the flexibility to author to define their own attributes. An attribute defined should start with data.

draggable

Allows user to drag an element or not which is placed in a web page. This draggable feature can be enabled by setting the values as true, false, or auto.

hidden

Hides the element by setting the value of an attribute as hidden.

item

Enables a user to group the elements. It takes two values-empty or URL.

itemprop

Enables a user to group the items. It takes two values-URL and groupvalue.

spellcheck

Enables a user to use the feature of checking the spelling of an element. The values are set by using the Boolean values-true or false.

subject

Sets the id for the element’s corresponding item.

Let’s do the following steps to edit the content of an HTML document:

Open a blank Notepad Document.

Add the code to the document:


<!DOCTYPE html>
    <head>
        <title> HTML 5 new Attributes </title>
    </head>
<body>
    <h2>Example of Editing the content</h2>
    <img alt="image 1 displayed" src="C:\Users\Public\Pictures\Sample Pictures\Desert.jpg" height="200px"
width="350px"/>
    <section item>
    <p contenteditable="true">Try to edit this text by overwriting any part of it.</p>
    <h3 itemprop="htmlhead">Introduciton to HTML 5 new attributes</h3>
    <p>Created by <span itemprop="Sandy">Sandy </span>.</p>
    </section>
</body>
</html> 

Save the document with the name of EdittingContent.html.

Open the HTML document in the web browser. The output is shown as below snapshot:

Editing Content in html 5

Let’s new learn about the new event attributes in HTML 5. Go through next button: