- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
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 −