Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8" />
- <title>HTML Tags Auditor</title>
- <style>
- body { margin: .5em auto; max-width: 85ch; font: 14pt/normal sans-serif }
- h2 { margin: 0; text-align: center }
- h2 span { font-size: 14pt }
- center { font-size: 12pt }
- p {
- display: block; margin: 1em auto; width: 30ch;
- background: #fdb; text-align: center; line-height: 1.3em;
- }
- #disp { display: none }
- a { margin-left: .5em }
- ul { margin: 0; padding-left: 1em }
- li { margin-top: .3em }
- #stats { margin: 1em 0; text-align: center }
- input { margin-left: 1.5em }
- input, label { cursor: pointer }
- #fs:checked ~ #out tbody tr:not(.supported),
- #fq:checked ~ #out tbody tr:not(.supported),
- #fq:checked ~ #out tbody tr.generic,
- #fg:checked ~ #out tbody tr:not(.generic),
- #fu:checked ~ #out tbody tr:not(.unsupported),
- #fl:checked ~ #out tbody tr:not(.unsupported),
- #fl:checked ~ #out tbody tr.rejected,
- #fr:checked ~ #out tbody tr:not(.rejected) { display: none }
- #fu { margin-left: 20.05ch }
- #fu, #fu ~ input, #fu ~ label { margin-top: .3em }
- #fs + label, #fu + label { display: inline-block; width: 5.8em }
- #fq + label, #fl + label { display: inline-block; width: 11.7em }
- #info { margin-top: 1em }
- #out { position: relative; margin: 1em auto; counter-reset: num }
- th { line-height: 1.3em }
- th { background: #555; color: #fff; font-weight: normal }
- td { padding: 0 .3em }
- td:first-child:before {
- display: block; position: absolute; left: -4.5ch; width: 2em;
- text-align: right; color: #000;
- counter-increment: num; content: counter(num) ".";
- }
- tr:nth-child(2n) td { background: #eee }
- .supported { color: #070 }
- .generic { color: #007 }
- .unsupported { color: #900 }
- .rejected { color: #a0a }
- code { padding: 0 .1em; background: #eef }
- #test { position: absolute; top: -100vw }
- </style>
- </head>
- <body>
- <h2>HTML Tags Auditor <span>v1.0.1</span></h2>
- <center>
- AGPL v3. March 2022.
- <a href="https://www.reddit.com/user/jcunews1">Reddit</a>
- <a href="https://greasyfork.org/en/users/85671-jcunews">Greasyfork</a>
- <a href="https://pastebin.com/u/jcunews">Pastebin</a>
- </center>
- <p id="nojs">This application requires Javascript.</p>
- <div id="disp">
- <div id="stats"></div>
- Filter:
- <input id="fa" type="radio" name="filter" checked />
- <label for="fa">All</label>
- <input id="fs" type="radio" name="filter" />
- <label for="fs">Supported</label>
- <input id="fq" type="radio" name="filter" />
- <label for="fq">Supported (unique object)</label>
- <input id="fg" type="radio" name="filter" />
- <label for="fg">Supported (generic object)</label>
- <br />
- <input id="fu" type="radio" name="filter" />
- <label for="fu">Unsupported</label>
- <input id="fl" type="radio" name="filter" />
- <label for="fl">Unsupported (allowed)</label>
- <input id="fr" type="radio" name="filter" />
- <label for="fr">Unsupported (rejected)</label>
- <table id="out">
- <thead><th>Tag Name</th><th>Object Name</th></thead>
- <tbody></tbody>
- </table>
- Notes:
- <ul>
- <li>
- Tag list is a combined list of HTML v2.0, v2.x, v3.0, v3.2, v4.0, v4.01, v5, including vendor specific Netspace Navigator v4.0 and Microsoft Internet Explorer v5.5 tags.
- </li>
- <li>
- HTML5 tag list is taken from <a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element">https://developer.mozilla.org/en-US/docs/Web/HTML/Element</a>.
- </li>
- <li>
- All other tags are taken from <a href="https://www.htmllint.org/tagslist.html">https://www.htmllint.org/tagslist.html</a>. List may not be accurate.
- </li>
- <li>
- Tags from other specifications such as XML, SVG, MathML, etc., are not included.
- </li>
- <li>
- Result is based on HTML tag usage in a Standard mode HTML5 document of this web browser.
- </li>
- <li>
- Unsupported but allowed tags work like <code>SPAN</code> tag, except that it's implemented as an unknown element object (<code>HTMLUnknownElement</code>). An unknown element object works same as generic element object (<code>HTMLElement</code>).
- </li>
- </ul>
- </div>
- <div id="test"></div>
- <script>
- nojs.style.display = "none";
- disp.style.display = "block";
- tags = "\
- A,ABBR,ABBREV,ABOVE,ACRONYM,ADDRESS,APPLET,AREA,ARRAY,ARTICLE,ASIDE,ATOP,AU,AUDIO,\
- B,BANNER,BAR,BASE,BASEFONT,BDI,BDO,BELOW,BGSOUND,BIG,BLINK,BLOCKQUOTE,BODY,BODYTEXT,BOX,BQ,BR,BT,BUTTON,\
- CANVAS,CAPTION,CENTER,CHOOSE,CITE,CODE,COL,COLGROUP,COMMENT,CONTENT,CREDIT,\
- DATA,DATALIST,DD,DDOT,DEL,DETAILS,DFN,DIALOG,DIR,DIV,DL,DOT,DT,\
- EM,EMBED,\
- FIELDSET,FIG,FIGCAPTION,FIGTEXT,FIGURE,FN,FONT,FOOTER,FORM,FRAME,FRAMESET,\
- H1,H2,H3,H4,H5,H6,HAT,HEAD,HEADER,HGROUP,HR,HTML,HYPE,\
- I,IFRAME,ILAYER,IMAGE,IMG,INPUT,INS,ISINDEX,ITEM,\
- KBD,KEY,KEYGEN,\
- LABEL,LANG,LAYER,LEFT,LEGEND,LH,LI,LINK,LISTING,\
- MAIN,MAP,MARK,MARQUEE,MATH,MENU,MENUITEM,META,METER,MULTICOL,\
- NAV,NEXTID,NOBR,NOEMBED,NOFRAMES,NOLAYER,NOSCRIPT,NOTE,\
- OBJECT,OF,OL,OPTGROUP,OPTION,OUTPUT,OVER,OVERLAY,\
- P,PARAM,PERSON,PICTURE,PLAINTEXT,PORTAL,PRE,PROGRESS,\
- Q,\
- RANGE,RB,RIGHT,ROOT,ROW,RP,RT,RTC,RUBY,\
- S,SAMP,SCRIPT,SECTION,SELECT,SERVER,SHADOW,SLOT,SMALL,SOURCE,SPACER,SPAN,SPOT,SQRT,STRIKE,STRONG,STYLE,SUB,SUMMARY,SUP,\
- T,TAB,TABLE,TBODY,TD,TEMPLATE,TEXTAREA,TFOOT,TH,THEAD,TILDE,TIME,TITLE,TR,TRACK,TT,\
- U,UL,\
- VAR,VEC,VIDEO,\
- WBR,\
- XMP".split(",");
- s = "";
- numSupported = 0;
- numUnsupported = 0;
- tags.forEach(t => {
- //generate element
- test.innerHTML = `<${t}></${t}>`;
- switch (t) {
- case "BODY": //there can only be one of this. use existing one instead.
- e = document.body;
- break;
- case "CAPTION": //these tags can only exist within a TABLE
- case "COL":
- case "COLGROUP":
- case "TBODY":
- case "TD":
- case "TFOOT":
- case "TH":
- case "THEAD":
- case "TR":
- test.innerHTML = `<table><${t}></${t}></table>`;
- e = test.querySelector(t);
- break;
- case "FRAME": //FRAME can only exist within a FRAMESET
- test.innerHTML = `<frameset><${t}></${t}></frameset>`;
- e = test.querySelector(t);
- break;
- case "HEAD": //there can only be one of this. use existing one instead.
- e = document.head;
- break;
- case "HTML": //there can only be one of this. use existing one instead.
- e = document.documentElement;
- break;
- default:
- e = test.firstChild;
- }
- //add result into table
- if (e) {
- s += `<tr class="${
- e.constructor.name === "HTMLUnknownElement"
- ? (numUnsupported++, "unsupported")
- : (
- numSupported++,
- (
- e.constructor.name === "HTMLElement"
- ? "supported generic"
- : "supported"
- )
- )
- }"><td>${t}</td><td>${e.constructor.name}</tr>`
- } else {
- numUnsupported++;
- s += `<tr class="unsupported rejected"><td>${t}</td><td>(Rejected)</td></tr>`
- }
- });
- stats.textContent = `Total tags = ${numSupported + numUnsupported}, Supported tags = ${numSupported}, Unsupported tags = ${numUnsupported}. See notes below.`;
- out.lastElementChild.innerHTML = s
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement