Table of Contents

E.3 Quoting Attribute Values

Outside of Flash, HTML attribute values can be quoted with single quotes, double quotes, or no quotes at all. The following tags are all valid in most web browsers:

<P ALIGN=RIGHT>
<P ALIGN='RIGHT'>
<P ALIGN="RIGHT">

But in Flash, unquoted attribute values are not allowed. For example, the syntax <P ALIGN=RIGHT> is illegal in Flash. However, both single and double quotes can be used to delimit attribute values. When composing text field values that include HTML attributes, we must be careful to quote attributes correctly, using one type of quote to demarcate the string itself and another to demarcate attribute values. For example:

// These examples are both valid.
myText = "<P ALIGN='RIGHT'>hi there</P>";
myText = '<P ALIGN="RIGHT">hi there</P>';
// This example causes an error because double quotation marks are
// used to demarcate both the string and the attribute.
myText = "<P ALIGN="RIGHT">hi there</P>";

For more information on using quotation marks to form strings, see Section 4.5.2.


Table of Contents