
- HTML Tutorial
- HTML - Home
- HTML - Overview
- HTML - Basic Tags
- HTML - Elements
- HTML - Attributes
- HTML - Formatting
- HTML - Phrase Tags
- HTML - Meta Tags
- HTML - Comments
- HTML - Images
- HTML - Tables
- HTML - Lists
- HTML - Text Links
- HTML - Image Links
- HTML - Email Links
- HTML - Frames
- HTML - Iframes
- HTML - Blocks
- HTML - Backgrounds
- HTML - Colors
- HTML - Fonts
- HTML - Forms
- HTML - Embed Multimedia
- HTML - Marquees
- HTML - Header
- HTML - Style Sheet
- HTML - Javascript
- HTML - Layouts
- HTML References
- HTML - Tags Reference
- HTML - Attributes Reference
- HTML - Events Reference
- HTML - Fonts Reference
- HTML - ASCII Codes
- ASCII Table Lookup
- HTML - Color Names
- HTML - Entities
- HTML - Fonts Ref
- HTML - Events Ref
- MIME Media Types
- HTML - URL Encoding
- Language ISO Codes
- HTML - Character Encodings
- HTML - Deprecated Tags
HTML Attributes
Attributes are used to set properties for an element like width and height of an image or canvas. All elements can have attribute and gives more information. Attribute has a name as well as a value −
For example −
<canvas id=”newCanvas” width=”400” height=”300”>
Other examples include −
<img alt=”alternate text”>
Including quotes around an attribute is not mandatory, according to HTML5 standard, but it’s always a good practice to include quotes.
Let us now see some examples of the usage of attribute in HTML −
HTML <ol> start Attribute
The start attribute of the <ol> element is used to set the start value of the first list item.
Syntax
Following is the syntax −
<ol start="num">
Above, num is the number set for the start value of the first list item.
Example
Let us now see an example to implement the start attribute of the <ol> element −
<!DOCTYPE html> <html> <body> <h1>Last Semester MCA Result</h1> <h2>Rank from 1-5</h2> <ol> <li>Steve</li> <li>David</li> <li>Kane</li> <li>William</li> <li>John</li> </ol> <h2>Rank from 5-10</h2> <ol start="5"> <li>Tom</li> <li>Jack</li> <li>Will</li> <li>Harry</li> <li>Tim</li> </ol> </body> </html>
Output
This will produce the following output −
HTML <textarea> autofocus Attribute
The autofocus attribute of the <textarea> element is used to set the autofocus to the textarea itself when the page loads. The autofocus attribute for the <textarea> element introduced in HTML5.
Syntax
Following is the syntax −
<textarea autofocus>
Example
Let us now see an example to implement the autofocus attribute of the <textarea> element −
<!DOCTYPE html> <html> <body> <h2>Interview Questions</h2> <p>Why do you want go for the Technical Writer Job Profile? (100 words)</p> <textarea rows="6" cols="70" autofocus> Write the answer in 100 words only... </textarea> <p>What are your strengths? (50 words)</p> <textarea rows="4" cols="70" autofocus> Write the answer in 50 words only... </textarea> </body> </html>
Output
This will produce the following output −
- Related Articles
- HTML data-* Attributes
- Attributes of HTML element
- HTML DOM attributes Property
- How to add and remove HTML attributes with jQuery?
- How to use height and width attributes in HTML?
- How to use min and max attributes in HTML?
- How do we include attributes for table columns in HTML?
- How to add attributes to an HTML element in jQuery?
- How do we embed custom data attributes on all HTML elements?
- What is the difference between id and name attributes in HTML?
- What are the attributes that work differently between React and HTML?
- How to remove all the attributes of an HTML element using jQuery?
- How to set the favicon size in CSS rather than HTML attributes?
- HTML file input control with capture and accept attributes is not working correctly
- How to decide the order of precedence of the style attributes in HTML?
