Basic HTML syntax summary

Block vs. inline

Example 1

A block element, like the following <div>

is always displayed as if it had a linebreak before and after it,

separated from surrounding text. A block element cannot be embedded within the start and end tags of an inline element - but inline elements can be embedded within the start and end tags of a block element.

An inline element like this <span> is displayed in the flow of the surrounding content.

Example 2

Content within a pre block element, like

if( p->x() > 0 )

appears exactly as written, but separated from surrounding content.

Content within a code inline element, like if( p->x() > 0 ) appears exactly as written and inline.


Other inline elements

The inline elements below are generally used to demarcate specific words or phrases within a paragraph. A browser generally supplies a default styling to inline elements so that, when rendered, they appear visually distinct. Custom CSS styling can be applied to inline elements to override browser default styling. Attributes can also be associated with inline elements for subsequent scripting purposes.

The span is used to apply custom styling to selected words within a paragraph. This element doesn't impose any default styling, as do the remaining inline elements described below. If a span contains no CSS styling, the text within the span will appear no different that the surrounding text. A span may also be used along with an attribute so that the element's style or content can subsequently be modified via javascript.

The em element indicates emphasized text.

This strong element indicates strongly emphasized text.

The abbr element indicates an abbreviation like FBI.

Use the cite element to cite a source like Wikipedia.

Use a dfn to indicate a definition: cruft - badly written code.

The samp is used to indicate sample output, like Abnormal Program Termination.

Use kbd to indicate a keyboard input, like rm -r *.

Use var to indicate a variable name like slkfjasdkjfa.

Use sup and sub for super- and sub-scripting, as in the Einstein Field Equation: Rab - 1/2 R gab = 8πG/c4 Tab

del and ins indicate deletedinserted text.

The br element
is used to explicitly
indicate a line break.

Here is an image:MSOE logo

Here is a link to MSOE's website