Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are single quotes valid in HTML/XHTML?

Are single quotes valid in HTML? And more specifically: XHTML strict.

<table width="100%"> <table width='100%'> 
like image 580
Andrew Avatar asked Feb 05 '10 21:02

Andrew


People also ask

How do I put single quotes in HTML?

You could use HTML entities: &#39; for ' &#34; for "

Can we use single quotes around attribute values?

Yes, that's acceptable. It works in browsers, and it's allowed by the specifications.

How do you escape a single quote?

Single quotes need to be escaped by backslash in single-quoted strings, and double quotes in double-quoted strings.


1 Answers

Yes, single quotes are valid.

From the XML spec:

[10]   AttValue  ::= '"' ([^<&"] | Reference)* '"'                   |  "'" ([^<&'] | Reference)* "'" 
like image 119
Quentin Avatar answered Sep 23 '22 06:09

Quentin