Home >Web Front-end >Front-end Q&A >What to do if the html tag is invalid

What to do if the html tag is invalid

藏色散人
藏色散人Original
2021-05-24 10:56:442934browse

Solutions to invalid html tags: 1. Assign the innerText of the element to the innerHTML of the element; 2. Use styles to present line breaks, with code such as "white-space: pre-line;".

What to do if the html tag is invalid

The operating environment of this article: Windows7 system, HTML5&&CSS3 version, DELL G3 computer

How to handle invalid HTML tags in the front-end string

1) Assign the innerText of the element to the innerHTML of the element. This can avoid escaping problems and make the HTML tags contained in the string effective.

<div ref="introContent" class="intro__content">{{intro}}</div>
mounted() {
        // let text = this.$refs.introContent.innerText;
        // this.$refs.introContent.innerHTML = text;
    },

2) Line breaks similar to carriage returns, using styles to present line breaks

word-break: break-all;
word-wrap: break-word;
white-space: pre-line;

Recommended tutorials: html video tutorial, css video tutorial

The above is the detailed content of What to do if the html tag is invalid. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn