html in varchar field?
I have a varchar(255) field in mysql that is used for displaying the title to a page and I received a request to superscript some characters for a particula开发者_如何学Pythonr title. I updated this title with some html but this doesn't render as expected.
Instead of H2O I get:
H<sup>2</sup>O
Thanks!
As others have said, you can't use HTML tags to highlight your title.
HOWEVER! You can use unicode literals.
Try this:
H²O
The ²
is the unicode character for the superscripted 2.
See this wikipedia article to see what superscripts and subscripts you can play with, and bear in mind that the U+xyz form is in hexadecimal, but the &#abc; form in HTML requires decimal values. U+b2 is ² in HTML.
This is unrelated to MySQL, the browser chooses to render it this way. Via http://en.wikipedia.org/wiki/HTML_element#Document_structure_elements
The title element must not contain other elements, only text.
That means you have either htmlspecialchars()
ed or htmlentities()
ed the text, either on input or on output.
(If you're talking about something like a <h1>
tag in the pages <body>
, at least. Otherwise the other answerer is right.)
精彩评论