Allowed HTML tags in Javadoc

Marco Eckstein picture Marco Eckstein · May 10, 2013 · Viewed 18.1k times · Source

The Checkstyle rule JavadocStyle does not allow the tag <u>. According to the docs, the checks were patterned after the checks made by the DocCheck doclet available from Sun. Unfortunately, I have not found DocCheck anywhere. Neither have I found any official documentation about allowed HTML tags in Javadoc. Is there any?

Answer

mernst picture mernst · Jun 20, 2015

Javadoc permits only a subset of HTML tags, as of Java 8.

Javadoc's doclint component enforces this restriction. You can disable all doclint warnings by passing -Xdoclint:none to javadoc, though you should consider fixing your Javadoc comments because otherwise the generated HTML API documentation may look bad or may omit content. (I usually use -Xdoclint:all,-missing to get warnings about everything except missing Javadoc @ tags.)

I have not found public documentation of the tags that doclint permits, but here is a list of its allowed HTML tags, which I gleaned from Java 8's file langtools/src/share/classes/com/sun/tools/doclint/HtmlTag.java.

A
B
BIG
BLOCKQUOTE
BODY
BR
CAPTION
CENTER
CITE
CODE
DD
DFN
DIV
DL
DT
EM
FONT
FRAME
FRAMESET
H1
H2
H3
H4
H5
H6
HEAD
HR
HTML
I
IMG
LI
LINK
MENU
META
NOFRAMES
NOSCRIPT
OL
P
PRE
SCRIPT
SMALL
SPAN
STRONG
SUB
SUP
TABLE
TBODY
TD
TFOOT
TH
THEAD
TITLE
TR
TT
U
UL
VAR

Update for JDK 9

JDK 9 permits a different set of tags than JDK 8 does. Here is a list of tags for both JDKs, with notes about those permitted by only one of the JDKs. Again, the data comes from the HTMLTag.java file.

A
BIG       // JDK 8 only
B         // JDK 8 only
BLOCKQUOTE
BODY
BR
CAPTION
CENTER
CITE      // JDK 8 only
CODE
DD
DFN       // JDK 8 only
DIR       // JDK 9 only
DIV
DL
DT
EM
FONT
FOOTER    // JDK 9 only
FRAME     // JDK 8 only
FRAMESET  // JDK 8 only
H1
H2
H3
H4
H5
H6
HEAD
HEADER     // JDK 9 only
HR
HTML
I
IFRAME     // JDK 9 only
IMG
INPUT      // JDK 9 only
LI
LINK
LISTING    // JDK 9 only
MAIN       // JDK 9 only
MENU
META
NAV        // JDK 9 only
NOFRAMES   // JDK 8 only
NOSCRIPT
OL
P
PRE
SCRIPT
SECTION     // JDK 9 only
SMALL
SPAN
STRONG
SUB
SUP         // JDK 8 only
TABLE
TBODY
TD
TFOOT       // JDK 8 only
TH
THEAD       // JDK 8 only
TITLE
TR
TT
U           // JDK 8 only
UL
VAR         // JDK 8 only