Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

<tt> vs <code> elements when writing Java docs

Tags:

java

html

javadoc

To represent keywords while writing Java Docs should I use the <code> element or the <tt> element? Are there specific situations when one should be preferred over the other?

like image 946
Geek Avatar asked Jan 26 '13 13:01

Geek


People also ask

Why is a Java Doc important?

JavaDoc tool is a document generator tool in Java programming language for generating standard documentation in HTML format. It generates API documentation. It parses the declarations ad documentation in a set of source file describing classes, methods, constructors, and fields.


2 Answers

For inline code in Javadocs,you should use {@code your-code-here}

See javadoc - {@code text} for more details.

Equivalent to <code>{@literal text}</code>.

Displays text in code font without interpreting the text as HTML markup or nested javadoc tags. ..

like image 157
Cephalopod Avatar answered Oct 17 '22 20:10

Cephalopod


From the W3C on TT.

HTML Reference

The element is a non-standard element.

HTML5 classifies it as a non-conforming feature.

Examples

No, really, don't use it.

And I think that answers the question. Choice of 2 elements, W3C says do not use one of them.

like image 28
Andrew Thompson Avatar answered Oct 17 '22 19:10

Andrew Thompson