Home  >  Article  >  Web Front-end  >  Detailed explanation of html browser automatically adding

 tag

Detailed explanation of html browser automatically adding
 tag

黄舟
黄舟Original
2017-07-08 13:49:433147browse

Problem scenario:

I clicked a request on page A, opened a new page (B), and passed HttpServlet on the backend Response.getWriter().write(html) method is used to write the information into the newly opened page B; [Digression: The reason for this is to solve the problem of the newly opened page being intercepted by the browser]

But there is no problem in IE6, 7, 8, ff; but in chrome, my newly written content is actually placed in the

 tag; 

Detailed explanation of html browser automatically adding <pre class= tag">

About html

 tag: 

pre element can define pre-formatting ized text. Text enclosed in a pre element usually preserves whitespace and newlines. The text will also be rendered in a fixed-width font.

 A common application of tags is to represent computer source code. 

Thoughts on the problem:

After discovering this problem, the first thing I thought of was: This should be because different browsers process code text information differently, chrome My form is displayed on the page as text. And is not an element in html format; so I think everything should be fine once this problem is solved.

At this time, I thought of the setting of htmlmeta information

Content-Type" content="text/html ;charset=utf-8" /> Setting this attribute should solve the problem.

After checking the document, it suddenly became clear:

1. text/html is the text in html format

2. text/plain is unformatted Text

3. text/xml ignores the encoding format specified by the xml header and defaults to us-ascii encoding

4. application/xml will Encode according to the encoding format specified by the xml header

Solution:

response.setHeader("Content-Type", "text/html");

The above is the detailed content of Detailed explanation of html browser automatically adding

 tag. 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