Battling Ampersands in Your Blog Design and Code

The history of the ampersand, the & on your keyboard, is a long and fascinating one.

Geoffrey Glaister writes in his “Glossary of the Book,” is a corruption of and (&) per se and, which literally means “(the character) & by itself (is the word) and.” The symbol & is derived from the ligature of ET or et, which is the Latin word for “and.”

One of the first examples of an ampersand appears on a piece of papyrus from about 45 A.D. Written in the style of early Roman capital cursive (typical of the handwriting of the time), it shows the ligature ET. A sample of Pompeian graffiti from 79 A.D. also shows a combination of the capitals E and T, and is again written in early Roman script. Later documents display a more flowing, less formal Roman lowercase cursive, which evolved into our italic, and the appearance of a ligature et becomes more frequent.

In the modern online world, the ampersand is a handy abbreviation for “and” to connect words, a popular element in computer programming, a character in emoticons &| , and a hassle for site code validation and publishing code in your blog posts.

Ampersands and Site Validation

Graphic of ampersands in various fonts copyright Lorelle VanFossenMany designers will work overtime to ensure their web design meets web standards and accessibility guidelines. Then they add a few advertisements, Google Maps, scripts, and other add-ons to their blog and errors pop up.

One of the most common design errors comes from the ampersand in URL and advertising links. Advertisers providing ad links are not necessarily to blame, though they could do a better job with the code they hand out, warn users that use of the code will break their perfect score for validation, and offer tips on how to fix the problem.

The blame rests with the limitation of browsers and passing information across the web. Most modern browsers handle ampersands well, but validation programs know that there are plenty of people using older browsers which can bork with ampersand usage.

In general, when using an ampersand in URL and advertising links, ampersands need to be converted into an HTML character entity, the browser translation of the ampersand.

& = &

For example:

http://example.com/index.php?query=test1&type=test&etc=test

typically won’t validate so you need to change the ampersand to its character entity in order to validate, which doesn’t change the effectiveness of the script.

http://example.com/index.php?query=test1&type=test&etc=test

You won’t see a difference when the link displays as the browser translates it into the ampersand, but the validation and problematic browsers will see the difference.

Here’s some real world examples. The first is an ad from Amazon.

<a href="http://www.amazon.com/gp/search?ie=UTF8
&keywords=dress%20code&tag=blahXYZ&index=dvd
&linkCode=ur2&camp=1789&creative=9325">Dress 
Code</a>...

In order to validate, each ampersand must be converted to &amp;:

<a href="http://www.amazon.com/gp/search?ie=UTF8
&amp;keywords=dress%20code&amp;tag=blahXYZ&amp;index=dvd
&amp;linkCode=ur2&amp;camp=1789&amp;creative=9325">Dress 
Code</a>...

Here is the Google search results link for “ampersand”:

http://www.google.com/search?
q=ampersand+errors+web+design+validation
&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:
official&client=firefox-a

To use this in your blog post and make it valid, according to web standards, you would have to convert the ampersands into HTML character entities:

http://www.google.com/search?
q=ampersand&amp;ie=utf-8&amp;oe=utf-8
&amp;aq=t&amp;rls=org.mozilla:en-US:official
&amp;client=firefox-a

In reality, you could remove everything after the search term “ampersand” and the link would still work.

To avoid many of the validation and browser issues with ampersands on your blog, consider the following recommendations:

See Also
a computer screen with a bunch of text on it

  • Avoid using an ampersand in a post title.
  • Avoid using an ampersand in your blog title.
  • Avoid using an ampersand in your links.
  • Avoid using an ampersand in your blog URL.
  • Convert all ampersand usage into its HTML character entity &amp;.

Publishing Ampersands in Code on Your Blog Posts

I write a lot of code in my WordPress blogs which often includes a lot of ampersands.

Ampersands, quote marks and apostrophes are the bane of online technical writers. WordPress and other blog services and word processors ignore ampersands, however they convert quotes into “smart quotes” that slant pretty with the font. These converted quote marks will not reproduce as viable code if they are copied and pasted into your own code. Thus, quote marks and apostrophes must be converted into HTML character entities.

The added emphasis was on purpose. There is nothing worst than offering code to your readers and having them come back and say it doesn’t work all because you didn’t convert the quotes.

I not only publish code, I show you how the code should really look, which means I have to double convert the ampersands in the code to make it display properly.

All begin with an ampersand.

For instance, to show you the ampersand as &, I have to type in &amp;. To show you that, I have to type in &amp;amp;, breaking it down character by character.

To display the quote mark character entity &#35;, I have to convert the ampersand into the &amp; and convert the number or pound sign (#) into it’s character entity, which begins with another ampersand as &amp;#35;, and follow that with the number 35 and the semi colon. To show you that, it looks like:

&amp;amp;&#35;35;

You don’t want to see what it took to create that. :D

Here are a few examples of how to display code sources, not just the code.

Ampersand & &amp; &amp;amp;
Quote Mark " &#34; &amp;&amp;#35;34;
Apostrophe ' &#39; &amp;&amp;#35;39;
Number sign (Pound) # &#35; &amp;&amp;#35;35;
Colon & &#58; &amp;&amp;#35;58;
Semi-colon ' &#59; &amp;&amp;#35;59;
Equals sign = &#61; &amp;&amp;#35;61;
Right Slash or Fraction / &#47; &amp;&amp;#35;47;
Less than < &#60; or &gt; &amp;&amp;#35;60;
Greater than > &#62; or &lt; &amp;&amp;#35;62;

That’s a lot of ampersands.

Related References

Picture of Lorelle VanFossen

Lorelle VanFossen

The author of Lorelle on WordPress and the fast-selling book, Blogging Tips: What Bloggers Won't Tell You About Blogging, as well as several other blogs, Lorelle VanFossen has been blogging for over 15 years, covering blogging, WordPress, travel, nature and travel photography, web design, web theory and development extensively as web technologies developed.

RECENT ARTICLES

TRENDING AROUND THE WEB

If you recognize these 7 signs, you were raised by parents who lacked compassion for you

If you recognize these 7 signs, you were raised by parents who lacked compassion for you

Parent From Heart

8 things a man will do when he wants out of a relationship (but doesn’t have the courage to admit it)

8 things a man will do when he wants out of a relationship (but doesn’t have the courage to admit it)

Hack Spirit

4 Zodiac signs that find happiness in the simplest things, not in wealth

4 Zodiac signs that find happiness in the simplest things, not in wealth

Parent From Heart

7 subtle signs someone is wealthy but doesn’t feel the need to prove it

7 subtle signs someone is wealthy but doesn’t feel the need to prove it

Global English Editing

Men who become more stubborn and difficult as they get older usually display these 8 habits

Men who become more stubborn and difficult as they get older usually display these 8 habits

Hack Spirit

The most turbulent and painful relationship of your life will be with someone who exhibits these 8 traits, according to psychology

The most turbulent and painful relationship of your life will be with someone who exhibits these 8 traits, according to psychology

Global English Editing