Help:Block and inline elements

Block and inline elements
Wikisource uses HTML to structure content and CSS to style it. Sometimes "wikicode" is used to simplify the HTML, but it's always rendered to HTML in the end.

HTML has two fundamental types of elements: inline elements and block elements. Generally, content is inline and block-level elements provide structure and grouping in the document. They have the following properties:

An HTML document is made up of block and inline elements nested inside each other. However, there is one important rule: it is not valid for an inline element to contain a block element. Inline elements can contain only other inline elements and block elements can contain either other block elements and/or inline elements.

If you do nest an inline element in a block element, it results in invalid HTML, which may not render correctly. It will also trigger a "HTML5 misnesting lint error", and will be listed automatically at Special:LintErrors/html5-misnesting.

It is possible to make inline elements be styled like block elements using the CSS  property. However, even if you set an inline element to have  or , the HTML is still structurally malformed if a   tag is placed inside it.

Paragraph tags
It is also invalid for any block element to be nested inside a paragraph tag, even though the  is itself a block element.

MediaWiki sometimes implicitly wraps text in  tags, which can occasionally cause issues, particularly with line-breaks in Wikicode inside templates that use. For example, the following would be incorrect:

This is because a  will occur inside the   tag.

If you only wanted a gap in the code for readability, you could use an HTML comment to avoid injecting a paragraph break:

if you actually want a paragraph break, then you should used a, not a.

Block and inline templates
Some Wikisource templates use inline elements (e.g. smaller) and some use block templates (e.g. center). This means that it is invalid to nest some templates inside others:

This is allowed: span inside div This is not allowed: div inside span

Some Wikicode constructs also end up as block-based HTML, and so they should never be placed inside an inline element:

Paragraph breaks

like this result in tags


 * Lists are
 * also block-based

Some inline span-based templates have block-based counterparts. For example, smaller is span-based, and smaller block is block-based.

You may nest block-based templates inside other block-based templates:

List of templates
Below is a non-exhaustive list of examples of common span and block templates:

Inline (span-based) templates


 * Font size templates:
 * smaller, x-smaller, ...
 * larger, x-larger, ...


 * font style templates:
 * letter-spacing
 * small-caps, uc, lc
 * dropinitial, largeinitial
 * blackletter
 * bold, italic color, ...


 * Inline items
 * gap
 * bar
 * illegible
 * redact

Block (div-based) templates


 * Font size templates:
 * smaller block, x-smaller block, ...
 * larger block, x-larger block, ...


 * Alignment
 * center, right
 * float left, float right
 * block center, block right


 * Indentation
 * hanging indent, text-indent


 * Rules
 * rule (uses )


 * Columns
 * div col
 * multicol


 * Tables and containers
 * AuxTOC
 * TOC begin