• Home
  • PHP
  • MySQL
  • Laravel
  • Demos
  • HTML
  • jQuery
  • Framework
  • Request Tutorial
PHP Lift
  • Home
  • Demos
  • Advertisement
PHP Lift
  • Home
  • PHP
  • MySQL
  • Laravel
  • Demos
  • HTML
  • jQuery
  • Framework
  • Request Tutorial
  • Follow
    • Facebook
    • Twitter
    • Google+
    • Pinterest
    • Youtube
    • Instagram
    • RSS
Home
HTML 5

Cool HTM5 Features, Part 2

May 1st, 2025 Ivan Dimov HTML 5 0 comments

Facebook Twitter Google+ LinkedIn Pinterest
Cool HTM5 Features, Part 2

The readonly attribute

Example:

<input type=’text’ readonly value=’55434343’>

The readonly attribute allows you to show a value in an input element without the user being able

New input types

HTML5 comes with a few new input types that can be used for different type of data. You can use the following new input types:

<input type=’url’>



<input type=’email’>



<input type=’tel’>



<input type=’date’>



<input type=’time’>



<input type=’search’>



<input type=’range’>



<input type=’number’>

The tel input type stands for telephone while the others should be self-evident. It is good to start using them where appropriate as there are subtle differences in the browsers when you use them. For example, on a mobile phone the tel input type might show the numbers first in the user’s browser and the date and time input types would show a proper input for retrieving the date and the time.

 The picture element

The picture element is an enhancement of the <img> tag. It allows you to offer different images to different devices so that you can optimize your webpages in terms of bandwidth and loading time. You use it in the following way:

<picture>

 <source srcset="logo-wide.png" media="(min-width: 600px)">



 <source srcset=”logo-extra-wide.png" media="(min-width: 1200px)">

 <img src="logo-narrow.png" alt="MDN">

</picture>

The img tag is again used as a fallback if none of the source conditions matches. In the example above, we display different images in the browser depending on the width of the browser window  that is viewing the webpage.

The form attribute

With HTML5, you can associate an input with a form even when the input is out of the form tag. Therefore, the input could be anywhere on the page and still be a part of a specific form. You just have to give an identifier to the form and then add the form attribute to the input and give the identifier in the attribute value. Here is how you do this:

<form>



<p>Sign up to retrieve news from us</p>



<input type=’email’ name=’email’ id=’news-form’>



<input type=’submit’ value=’Submit’>



</form>



<div>



<input type=’tel’ form=’news-form’ name=’tel’>



</div>

Reversed ordered lists

Ordered lists in HTML typically start counting list items from 1 and increment as you add items to them. You can reverse the order with the reversed attribute making them start from the highest to the lowest number instead of the opposite. Here is how one can achieve this:

<ol reversed>



<li>Do the dishes.</li>



<li>Make breakfast</li>



<li>Enjoy life</li>



</ol>

The minlength attribute

In the previous article we have talked about how you can use the pattern attribute and the maxlength attribute to check for a specific length of the input that the user has entered.  You can also use the minlength attribute to check for a minimum number of characters that the input needs to have to submit the form.

Example:

<input type=’tel’ required minlength=’8’>

 

Share this:

  • Click to share on X (Opens in new window) X
  • Click to share on Facebook (Opens in new window) Facebook

Related

  • Tags
  • HTML5
Facebook Twitter Google+ LinkedIn Pinterest
Next article Programming Languages for Better Job Opportunities
Previous article PHP Beyond 2023: Unfurling the Road Less Traveled

Ivan Dimov

Ivan is a student of IT, a freelance web designer/developer and a tech writer. He deals with both front-end and back-end stuff. Whenever he is not in front of an Internet-enabled device he is probably reading a book or traveling. You can find more about him at: http://www.dimoff.biz. facebook, twitter

Related Posts

7 HTML attributes that you must learn today! HTML 5
May 4th, 2025

7 HTML attributes that you must learn today!

Cool HTML5 features HTML 5
May 1st, 2025

Cool HTML5 features

How to show Image before upload JavaScript & HTML5 FileReader() API
May 1st, 2025

How to show Image before upload JavaScript & HTML5 FileReader()

Leave a Reply Cancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Subscribe
Get new posts by email:
Powered by follow.it
Advertisement
Like us
Recent Posts
  • Introduction to Git for version control
  • 7 JavaScript array methods you must know as a programmer
  • Why Use MongoDB and When to Use It?
  • Useful PHP built-in functions
  • 7 HTML attributes that you must learn today!
Categories
  • API
  • Bootstrap
  • Bot
  • CSS
  • CSS 3
  • Database
  • Designing
  • Framework
  • Guide
  • HTML
  • HTML 5
  • JavaScript
  • jQuery
  • Laravel
  • MySQL
  • Node.js
  • oAuth
  • Payment
  • PHP
  • Python
  • Social
  • Tips
  • Web 3.0
  • WordPress
Weekly Tags
  • PHP
  • How to
  • javascript
  • laravel
  • MYSQL
  • PHP framework
  • css
  • jQuery
  • HTML to PDF
  • Web Development
  • About
  • Privacy Policy
  • Back to top
© PHPLift.net. All rights reserved.