W3C Validation and code in website text
If I were to take the error logs of a file, and put them on a properly formatted HTML page, the page might not pass validation by W3C's validation tool because the error text contains markup that the validation tool gets confused with. How can I properly mark such text such that the validation tool realizes that 开发者_如何学编程it's reading what should be interpreted as a normal string and not markup?
You need to convert the following characters into their HTML entities (stolen from the PHP manual on htmlspecialchars()
):
'&' (ampersand) becomes '&'
'"' (double quote) becomes '"'
''' (single quote) becomes '''
'<' (less than) becomes '<'
'>' (greater than) becomes '>'
If it really is a normal string, then you should represent the characters that have special meaning in HTML with their respective entities. <
to <
etc.
This will, of course, cause browsers to render those characters as text and not tags.
If you want browsers to render them as tags, then they aren't a normal string and they are a validity error.
精彩评论