P
P
Pavel Kityan2014-08-15 18:07:25
HTML
Pavel Kityan, 2014-08-15 18:07:25

Can there be a validation error for HTML generated dynamically?

In general, this question arose in connection with the need to shove our HTML code into EPUB3.
Here I have, for example, a valid XHTML file that can be placed in an EPUB container.
And it also comes with a js script that picks the DOM on the fly. And he can screw up in terms of auto-closing single tags or using non-existent attributes.
On the one hand, this does not interfere with the validation of the HTML file. On the other hand, during execution - what can happen? What is the general policy on this? At runtime, so to speak, of browsers and EPUB reader engines?
For example, if I don't escape & in & in an XHTML file is an error, but if I dynamically insert & is this also an error? Or am I forgetting the closing tag? Or am I using <br> instead of <br />?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Evgeny Petrov, 2014-08-15
@Petroveg

Show me a site where the document is served with the title application/xml+xhtml.
If the title is text/html, it means that your torment with the XML syntax is absolutely in vain.
It's not escaping, it's entities
I can write
or
it's also entities.
Parsing errors will not happen with &, with <, or with >, but it is better to write text with entites instead of & < > " ' simply because it can be used not only on the site, but also where there is XML.
A script that messes with closing tags when inserting strings using innerHTML is a serious problem, and XML has nothing to do with it. Imagine that such a script will not close the link. Therefore, it is better not to do the generation of string content with subsequent feeding to the parser. There are DOM methods for error-free insertion. Let them often slower, but reliable.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question