Lably
Skip to content

Div and span

HTML elements used to define parts of a document

  • 6 min read
  • 5 chapters
  • 4 labs on Lably

Learn it on Lably

<span> represents an inline portion of a document, for example words within a sentence. <div> represents a block-level portion of a document such as a few paragraphs, or an image with its caption. <div> stands for division. The elements allow semantic attributes (e.g. lang="en-US"), CSS styling (e.g., color and typography), or client-side scripting (e.g., animation, hiding, and augmentation) to be applied.

<div> defines a 'division' of the document, a block-level item that is more distinct from elements above and below it than a span of inline material.

Examples

For example, to make a certain part of text inside a paragraph red, <span> can be used as follows:

Sign in to keep reading

4 more chapters are free with a Lably account.

More in Computing and communication