Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to check if an HTML element is supported by a browser

Tags:

javascript

Is there a way to check if a tag is valid html tag and / or supported by the browser ? Like if I type text "hi" in a set of p1 tag, browsers wont show anything in display, but p1 is not a valid html tag. How to check this using javascript ?

like image 887
pokrate Avatar asked Mar 30 '10 21:03

pokrate


1 Answers

If you want to test whether HTML5 tags and attributes are supported, you can use Modernizr—it's a JavaScript file you include which does the work for you. It also adds support for things like <section> and <header> to the browser using JavaScript so you can go ahead and use them without fear.

If you want to be sure that an XHTML 1.0 or HTML4 tag is supported… well, you can assume it is. No one uses Netscape 4 any more.

like image 57
Samir Talwar Avatar answered Nov 15 '22 07:11

Samir Talwar