Home >Web Front-end >Front-end Q&A >What to do if the html tag is invalid
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;".
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!