Follow

Guide to: Using HTML Tags/Characters in Labels

When adding contributor-facing labels to your CML elements, there are times when you may need use HTML tags in your label's text, or add markup to style your label.  Because CML labels do not accept HTML Tags, you will need to use "escape characters" in this scenario.  In this article we will explain escape characters and their various uses in CML labels.
 
What is an escape character?
An escape character is an alternative version of a symbol. In HTML, there are some characters that are considered reserved, such as less than (<) and greater than (>) signs, which signify tags. These types of reserved characters must be replaced by using the character’s code name or number, which are HTML codes for that particular character, so that the character will be read as a regular character and not a reserved HTML character.
 
Escape characters will always begin with the ampersand symbol (&) and end with a semicolon symbol (;). The characters in between the ampersand and the semicolon make up the specific code name or number for a particular character. The specific code name is the entity name and the code number is the entity number. The entity name and entity number are interchangeable in most cases, but some browsers may not support all entity names. Some examples of common escape characters are as follows:
 

Character Description Entity Name Entity Number
& Ampersand &amp; &#38;
Less than &lt; &#60;
Greater than &gt; &#62;
  Non-breaking space* &nbsp; &#160;


*Non-breaking space: browsers will shorten spaces in HTML documents from multiple spaces to one space. If more than one space is needed in an HTML document, the escape character for a non-breaking space is recommended to replace any spaces following the first space.
 
 
When and how do I use escape characters?
The best time to utilize escape characters is when there are reserved characters within HTML tags and in HTML tag labels. Below are some examples of when and how to use escape characters.  Pay close attention to Example 3 as it will show you how to add escape characters to a contributor-facing label in your CML: 
 

  Example 1 Example 2 Example 3
Original <p>Bob & Fred are going to the movies</p> <h2>Is 71 > 13 & 22 < 5? </h2> <cml:text label=“What is your favorite <span class=“orange”>book</span>? ”/>
With escape characters <p> Bob &amp; Fred are going to the movies</p>
 
<h2>Is 71 &gt; 13 &amp; 22 &lt; 5? </h2> <cml:text label=“What is your favorite &lt;span class=‘orange’&gt; book &lt;/span&gt;?”/> *
Looks like Bob & Fred are going to the movies Is 71 > 13 & 22 < 5? What is your favorite book?

*When placing a tag within a tag’s label, change all double quotation marks (“) to single quotation marks (‘)
 
 
For further reading, please visit: http://www.w3schools.com/html/html_entities.asp


Was this article helpful?
0 out of 0 found this helpful


Have more questions? Submit a request
Powered by Zendesk