HTML handling

Learn how to translate HTML content with the DeepL API.

By default, the translation engine does not take HTML tags into account. By setting the tag_handling parameter to html, the API will process HTML input by extracting the text out of the structure, splitting it into individual sentences, translating them, and placing them back into the HTML structure.

For the translation of (non-HTML) XML content please see XML Handling

Splitting of newlines

The default value for the split_sentences parameter for all requests where tag_handling=html is nonewlines, meaning the translation engine splits on punctuation only, ignoring newlines.

The default value split_sentences for text translations where tag_handling is not set to html is 1, meaning the translation engine splits on punctuation and on newlines.

Disable translation of elements

To prevent the translation of elements in the HTML structure, the translation engine respects the translate="no" and class="notranslate" attributes. In the following example, the translate="no" attribute is used to prevent translation of the paragraph:

Example request
<!DOCTYPE html>
<html>
  <body>
    <h1>My First Heading</h1>
    <p translate="no">My first paragraph.</p>
  </body>
</html>
Example response
<!DOCTYPE html>
<html>
  <body>
    <h1>Meine erste Überschrift</h1>
    <p translate="no">My first paragraph.</p>
  </body>
</html>

Last updated