: (Colon) is ASCII code point 58 (0x3A), Unicode U+003A, and a printable punctuation character. It introduces what follows from what precedes — a list, an explanation, a revelation — acting as a grammatical drumroll that says "here's what I mean." Programming relies on the colon in wildly divergent ways. Python uses it to open every block — if, for, def, class — making it the character that most often triggers an IndentationError on the next line when something goes wrong. JSON and JavaScript object literals use : to bind keys to values ({"name": "Alice"}). In URLs, it separates the scheme from the authority (https://) and the host from the port number (localhost:8080). C and C++ deploy it in the ternary operator (condition ? a : b), label definitions, and scope resolution (std::vector). The trap lurks in YAML, a format that treats the colon as its key-value separator: a string like title: Mission: Impossible splits at the first colon, making the value just "Mission" and leaving the parser confused about what "Impossible" is doing there. Quoting the value fixes it, but YAML's eagerness to interpret bare strings catches everyone at least once. The mark dates to antiquity, where Greek and Latin scribes placed a raised dot between clauses to indicate a pause longer than a comma but shorter than a full stop. UTF-8 encodes it as a single byte 0x3A. Unicode classifies it as Po (Punctuation, Other) with the name COLON. The visually similar ratio symbol ∶ (U+2236) is technically a math operator, and the modifier letter triangular colon ː (U+02D0) from phonetics is a different character entirely — neither will function where a parser expects ASCII 0x3A.
const char *addr = "example.com:443";const char *p = strchr(addr, ':'); // find host:port delimiterint port = p ? atoi(p + 1) : 0; // parse port after ':'
The colon inherited its natural language role ('what follows explains what came before') into computing. It separates keys from values (JSON), labels from statements (C goto), type annotations (TypeScript: string), namespaces (std::cout), and drive letters from paths (C:\).
In C++, :: is the scope resolution operator (std::vector, MyClass::method). In Rust, it accesses associated functions (String::new()). In PHP, it accesses static members. In CSS, :: prefixes pseudo-elements (::before, ::after), distinguishing them from pseudo-classes (:hover).
The colon separates the scheme from the rest (https:, mailto:, file:). It also separates host from port (localhost:3000). In IPv6 addresses, colons separate address groups ([::1]). These different uses within the same URL format are parsed positionally by RFC 3986.
Python uses : to start code blocks (if x:, for i:, def f():) — it replaces the { of C-like languages and was chosen for readability. YAML uses : for key-value pairs (key: value) because it's visually clean and unambiguous. Both choices prioritize human readability.