whitespace

Characters that show as blank space, such as spaces, tabs and line breaks.

In more detail

Many tools split text into words at whitespace, and many formats ignore extra whitespace between items. In some languages and formats, such as Python and YAML, indentation whitespace is part of the syntax, so a misplaced space changes meaning. Because tabs and spaces look alike, it is a frequent source of hard-to-see mistakes in data and in code.

Examples

A Jinja template keeps its whitespace in the rendered file, which matters for strict configuration formats.
IFS= read -r line  # keeps leading spaces
printf '[%s]\n' $var  # unquoted: split on whitespace
In the browser: In the DOM, the line breaks and indentation between tags become whitespace text nodes. That is why childNodes often contains more entries than you expect, while children does not.
Jakarta Validation: @NotBlank rejects null, empty and whitespace-only text.
Values piped into rpk with echo end with a newline, so the course calls strip after decoding.
In this course: Arguments about whitespace are exactly the kind of review comment a formatter should make unnecessary. In Python, indentation whitespace is also part of the syntax.

Related terms

Taught in

References

Certification courses