Web Dev Notes

Blog about web development by Robert Dawson

HTML5 tag name validator

This form validates if a user's text string matches that of a valid HTML5 tag name.

Here is the regex:

/^(!(--|DOCTYPE)|a(bbr|ddress|r(ea|ticle)|side|udio)*|b(ase|d(i|o)|lockquote|ody|r|utton)*|c(a(nvas|ption)|ite|o(de|l(group)*|mmand))*|d(atalist|d|e(l|tails)|fn|iv|l|t)*|em(bed)*|f(i(eldset|g(caption|ure))|o(oter|rm)|rame(set)*)|h(ead(er)*|[1-6]|group|r|tml)|i(frame|mg|n(s|put))*|k(bd|eygen)|l(abel|egend|i(nk)*)|m(a(p|rk)|e(nu|t(a|er)))|n(av|oscript)|o(bject|l|pt(group|ion)|utput)|p(aram|r(e|ogress))*|q{1}|r(p|t|uby)|s(amp|cript|e(ction|lect)|mall|ource|pan|t(rong|yle)|u(b|mmary|p))*|t(able|body|d|extarea|foot|h(ead)*|i(me|tle)|r(ack)*)|u(l)*|v(ar|ideo)|wbr)$/i