By default, Jsoup will display only block-level elements with a trailing line break. Inline elements are displayed without a line break.
Given a body fragment, with inline elements:
<select name="menu">
<option value="foo">foo</option>
<option value="bar">bar</option>
</select>
Printing with Jsoup:
Document doc = Jsoup.parse(html);
System.out.println(doc.html());
Results in:
<html>
<head></head>
<body>
<select name="menu"> <option value="foo">foo</option> <option value="bar">bar</option> </select>
</body>
</html>
To display the output with each element treated as a block element, the outline
option has to be enabled on the document's OutputSettings
.
Document doc = Jsoup.parse(html);
doc.outputSettings().outline(true);
System.out.println(doc.html());
Output
<html>
<head></head>
<body>
<select name="menu">
<option value="foo">foo</option>
<option value="bar">bar</option>
</select>
</body>
</html>
Source: JSoup - Formatting the <option> elements