HTML5: How To Use And Tags


Among several new tags that are available in HTML5, Specifications (such as: figurefigcaption, and aside), detail and summary tags, in my opinion, are the most useful. With these new tags you can hide some of the long content and display only the summary.
post cover details HTML5: How to Use <DETAILS> and <SUMMARY> Tags
We actually often see this effect around, but most of them are still built upon JavaScript or its brother: jQuery, which most people don’t understand. Now, with these new elements – detailsand summary – things will get easier.
So, let’s see how tags work in a real case scenario.
In this demo we are going to summarize a product description. First let’s create a ‘details’ tag and then put all the content along with the ‘summary’ tag inside it, like in the example below:
  1. <details>  
  2.   <summary>MacBook Pro Specification</summary>  
  3.     <ul>  
  4.       <li><strong>13.3-inch LED-backlit glossy widescreen display</strong> with edge-to-edge, uninterrupted glass (1280 x 800-pixel resolution).</li>  
  5.       <li><strong>2.4 GHz Intel Core i5 dual-core processor</strong> with 3 MB shared L3 cache for excellent multitasking.</li>  
  6.       <li><strong>Intel HD Graphics 3000</strong> with 384 MB of DDR3 SDRAM shared with main memory.</li>  
  7.       <li><strong>500 GB Serial ATA hard drive</strong> (5400 RPM)</li>  
  8.       <li><strong>4 GB installed RAM</strong> (1333 MHz DDR3; supports up to 8 GB)</li>  
  9.     </ul>  
  10. </details>  
In that example, I’ve added MacBook Pro specification detail, and now let’s see how the browser renders those tags.
details demo ch HTML5: How to Use <DETAILS> and <SUMMARY> Tags
I also have added a title and more descriptions of the product above the details to make the above demo more sensible to you. So, what do you think? It’s quite easy, right?

Browser Supports

However, before you rush to apply this tag to your entire website, it should be noted that the details and summary tag is currently only supported on Chrome 12 and above.
Even the latest Firefox doesn’t support them yet.
details demo ff12 HTML5: How to Use <DETAILS> and <SUMMARY> Tags
So, if you want to apply this tag, you need to include a fallback function for unsupported browsers. The good news it, it’s simple; you can use this details polyfill, which will automatically replicate the tag functionality for old browsers.
Download this file and link it to the html document along with the jQuery (1.7+ at minimum) and make sure you place the polyfill before the close body tag.
And inside the head tag, insert the following conditional tag to include HTML5shiv for IE8 and earlier, otherwise the Internet Explorer will not recognize these new tags.
  1. <!--[if lt IE 9]><script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script><![endif]-->  
Now let’s see how it turns out in Internet Explorer:
details demo ie8 HTML5: How to Use <DETAILS> and <SUMMARY> Tags
And it now works on Internet Explorer as well.

Conclusion

Creating such a hide-and-show effect with JavaScript or jQuery is actually relatively easy, but having it natively supported from the browser is definitely a much easier solution for many people. Whether you want to do it in JavaScript or in HTML5, it’s your decision. Thanks for reading, and I hope you enjoyed it.

Penulis : Unknown ~ Sebuah blog yang menyediakan berbagai macam informasi

Artikel HTML5: How To Use And Tags ini dipublish oleh Unknown pada hari . Semoga artikel ini dapat bermanfaat.Terimakasih atas kunjungan Anda silahkan tinggalkan komentar.sudah ada 0 komentar: di postingan HTML5: How To Use And Tags
 

0 comments:

Post a Comment

Leave Me a Comment Below. Thanks :)