Skip to main content

Use Hyphens Instead of Spaces

We all like our spaces. Spaces are important. We use them to separate words in sentences because without them paragraphs would be unreadable. Itwouldbeextremelydifficulttoreadanythingofanylengthifspaceswereelimitatedentirely!Doyouagree? So spaces are a necessity. 

However, spaces can also be dangerous.  Too many spaces can make text difficult to read as well. They can be used incorrectly for purposes for which they were not designed. Sometimes, users engage them to arrange items on a document or website prior to obtaining the knowledge or skills to arrange items properly.  

File naming is no exception. Many tend to use spaces to separate words in file names. This practice can create an undesirable and chaotic effect when a file will be used in program code or on the web. It is likely you have seen a URL with strange symbols around words making it difficult to remember. On some state webpages you may have seen a link with %28 or %29. This would be the way a browser translates open and close parentheses respectively ( ). The most common type you will see is %20. This is, of course, the browser's translation of a space. For example, if a file is named "executive order 2022 10.pdf" and located on the Executive Order page of illinois.gov, the URL seen in the  address bar of the browser would be https://www.illinois.gov/government/executive%20order%202022%2010.pdf".

These special characters can be extremely cumbersome, especially when creating a hyperlink to that file. In an effort to prevent this difficulty, we remove all spaces within file names and replace them with a hyphen. Doing so wil eliminate the undesired special characters we see in the URL. Additionall, we still have a clean break between words, maintaining an easy-to-read file name.  

Using the previous example, we eliminate all spaces in the Executive Order and replace them with hyphens; the new file name becomes "executive-order-2022-10.pdf". Now when a browser reads the name of the file, it will have no issue with the name, and we see no surprise characters in the URL:  https://www.illinois.gov/government/executive-order-2022-10.pdf.

If file name = executive order 2022 10.pdf

Web address = https://www.illinois.gov/government/executive%20order%202022%2010.pdf

If file name = executive-order-2022-10.pdf

Web address = https://www.illinois.gov/government/executive-order-2022-10.pdf