Why hyphens are used more in http urls


The use of hyphens (-) instead of underscores (_) in URLs, particularly for domain names and paths, is primarily based on historical and technical reasons:

  1. Standards and Conventions: The standards for URLs and domain names were established by organizations like the Internet Engineering Task Force (IETF) and the Internet Corporation for Assigned Names and Numbers (ICANN). These standards historically favored the use of hyphens over underscores.

  2. Domain Name System (DNS) Limitations: In domain names, only alphanumeric characters (A-Z, 0-9) and hyphens are allowed. Underscores are not permitted in domain names according to DNS specifications. This is largely because the DNS was designed to be compatible with existing naming systems and protocols which did not use underscores.

  3. Search Engine Optimization (SEO): Search engines like Google treat hyphens as space, allowing them to distinguish and index words separately in a URL. For example, example-site.com is read as “example site,” whereas example_site.com would be interpreted as a single word, “examplesite.” This impacts how websites are indexed and found via search engines.

  4. Usability and Clarity: Hyphens are generally more visible in URLs and are less likely to be overlooked or cause confusion. For instance, underscores might not be as visible when a URL is underlined, as is common in many hyperlinks.

  5. Historical Precedence: Early web standards and practices set a precedent for using hyphens, and this convention has continued due to inertia and the desire for backward compatibility.

In the paths of URLs (the part after the domain name), underscores are technically allowed and do work in modern web systems. However, due to the reasons mentioned above, particularly around SEO and consistency with domain naming conventions, hyphens are generally preferred and more commonly used.


Author: robot learner
Reprint policy: All articles in this blog are used except for special statements CC BY 4.0 reprint policy. If reproduced, please indicate source robot learner !
  TOC