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 spacesprintf '[%s]\n' $var # unquoted: split on whitespaceIn 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
- YAML — A human-friendly text format for configuration, where indentation shows structure.
- Jinja template — A text file containing Jinja expressions that Ansible fills in with each host's variables to produce a finished file.
- escape sequence — A backslash followed by a character that together stand for something hard to type directly, such as \n for a line break.
- IFS — The internal field separator: a shell variable listing the characters that word splitting and read cut text at.
- newline — The invisible character that ends a line of text, written \n in most programming languages.
- word splitting — The step where bash cuts the result of an unquoted expansion into separate words at spaces, tabs and newlines.
- DOM node — One object in the DOM tree, such as an element, a run of text or a comment.
- element traversal properties — DOM properties such as children, firstElementChild and nextElementSibling that move between elements while skipping text and comment nodes.
- Jakarta Validation — The Jakarta standard for declaring input rules as annotations on fields, such as @NotBlank and @Positive, and checking them automatically.
- string — A sequence of characters, that is, a piece of text.
- split() — A string method that cuts a string into a list of parts, at white space by default or at a separator you give.
- indentation — The spaces at the start of a line, which in Python decide which statements belong inside a def, if, for or other block.
- blocklist — A list of values, such as addresses, domains or file hashes, that a control refuses outright.
- code formatter — A tool that rewrites source code into a consistent layout, such as indentation and spacing, without changing what it does.
Taught in
- Templates With Jinja — Ansible Configuration Management at Scale
- The Unquoted Variable: Splitting And Globbing — Bash Scripting & Command Line Automation
- The Field Separator, And Reading Lines Safely — Bash Scripting & Command Line Automation
- Finding Lines: grep And Regular Expressions — Bash Scripting & Command Line Automation
- Script Input And Output: read, Heredocs, printf — Bash Scripting & Command Line Automation
- Arguments: Dollar One, Dollar At, shift — Bash Scripting & Command Line Automation
- find And xargs — Bash Scripting & Command Line Automation
- Modern DOM Querying: querySelector, closest And matches — Frontend Architecture & Web Platform
- Validation — Modern Java: Virtual Threads & High-Throughput Services
- A Consumer In Python — Apache Kafka & Event Streaming
- Your Python Folder And A First Program — Hands-on Python: Complete Video Course & Book
- A Sample Program, Explained — Hands-on Python: Complete Video Course & Book
- Literals, Identifiers And Keywords — Hands-on Python: Complete Video Course & Book
- Split And Join — Hands-on Python: Complete Video Course & Book
- HTML Forms And Dynamic Programs — Hands-on Python: Complete Video Course & Book
- Injection In All Its Forms — Application Security & Threat Modeling for Engineers
- What To Automate Away — Automated Testing, TDD & Quality Engineering
- Print, Input And The Casts Between — PCEP Certified Entry-Level Python Programmer (PCEP-30-02) Exam Prep
- String Methods The Exam Picks — PCAP Certified Associate in Python Programming (PCAP-31-03) Exam Prep
- Strings Sprint — PCAP Certified Associate in Python Programming (PCAP-31-03) Exam Prep
- Comprehensions, Closures And Files Sprint — PCAP Certified Associate in Python Programming (PCAP-31-03) Exam Prep
- Jinja Templates: One File, A Different Text Per Host — RHCE in Ansible (EX294): Automate Red Hat Systems
References
- Jinja: whitespace control
- POSIX definitions: white space
- MDN: Handling whitespace
- Jakarta Validation 3.0 specification
- Java SE 21 API: String
- Python str.strip
- Built-in types: str.isspace
- Unicode: White_Space property (UAX #44)
- Python reference: indentation