Hello readers, Today we will discuss about the HTML5 Attributes. Basically attributes are used to define some additional information about the HTML elements. As there are various global and custom attributes used in HTML5.
Features of HTML5 attributes:-
It provides additional information about the element.
Some attributes are defined globally and therefore can be easily used on any HTML element.
While some other attributes are defined for some particular HTML elements.
These are always specified in the start tag in a document.
All attributes have a specific name and value assigned to it .
These are case insensitive.
Below is the list of various updated Global attributes of HTML5
Contenteditable -: It defines that whether the user can edit the the content in a document.
Contextmenu -: It specifies to a menu corresponding to the given element.
Draggable -: It specifies if an element is draggable or not.
Dropzone -: It defines if the data which is dragged is copied, moved or linked when it is been dropped.
Hidden -: It specifies whether the element used is visible or not.
Spellcheck -: It specifies whether the content used in the document need to have its spelling and grammar checked or not.
Translate –: It specifies whether the content of the document need to be translated or not.
Data-* - It acts as a prefix for any attribute that we want to add with an element and it basically help to create our own attribute. E.g <button type =”button” data-foo=”foo”>My Button </button>
Below is the list of various Element Attributes -
There are few attributes among several of them are applied to multiple elements. Below are some attributes name with the elements are explained briefly. These are - :
async (script element) :- This attribute helps to execute the script before the whole page gets loaded.
autocomplete(input element) -: This attribute auto-completes the text entered into the input elements having a valid type assigned to it. It uses valid values such as “on”and “off” by enabling the input elements to show autocomplete feature when one and disable on off.
Synatx :- <input type =”email” name=”email” autocomplete =”on” />
autofocus (input , select , textarea and button elements) :- This attribute automatically focuses the element whenever the page is loaded.
charcet (meta element) :- This attribute defines the character encoding for a page easily understandable for the developers ,mostly used is UTF-8.
Dirname(input and textarea element):- This attribute basically defines the text direction whether to choose ltr(left to right) or rtl(right to left) on input and textarea elements.
disabled(fieldset elements ) :- This attribute help the fieldset element to disable all elements that are within the fieldset.
<legend> Personal Information:</legend>
First Name: <input type =”text” /><br />
Ladt Name: <input tyle =”text” /> <br />
Some new attributes for Form :-
formaction(input and button elements) :- This attribute helps to send the submitted data to varioius locations for further processing whenever a form is submitted. It uses a url which describes where we the data to be send.
Syntax :- First name : <input type =”text” name=”FirstName” formaction = ”MyProcessingPage.asp” />
formenctype(input and button elements) :- This attribute allows us to override the method attribute of a form belonging to input or button elements. It uses to valid values i.e get and post.
Formnovalidate(input and button elements) :- It amin work is to exclude the elements whenever the form validates.
Syntax :- <input type =”text”? Formnovalidate =”formnovalidate” name=”Firstname” />
hreflang( area element) :- This attribute defines the language of the targeted url for the area element.
label(menu element) :- This attribute represents the headings for a group of elements belonging to the menu element.
< menu label =”Edit”>
<button type =”button” onclick=”edit_cut()”>Cut</button>
<button type =”button” onclick=”edit_copy()”>Copy</button>
<button type =”button” onclick=”edit_paste()”>Paste</button>
max(input element) :- This attribute will set a maximum limit on the user's input either a numerical or date limit depending upon the type attribute of the input elements used.
Syntax :- <input type =”number” name=”age” min=”1” max=”100” />
maxlength(textarea element> :- This attribute defines the limit to the number of characters that can be entered in a textarea element.
<textarea maxlength =”100”>
some text is to be entered here.
media ( a and area element) :- This attribute optimizes the media or a device to some targeted url.
min(input element) :- Using this attribute user will be able to set a minimum limit on the user's input it can be a numerical or date limit depending upon the type attribute of the input elements used.
multiple(input element) :- This attribute works for multiple values selected by the user when the type is set to either email or file.