Characters in attributes being converted to unicode

落花浮王杯 提交于 2019-12-13 20:20:03

问题


I'm adding HTML Tag Attributes to a section in a Gantry 5 layout, using the section's settings. But any special characters are rendered as Unicode Hex Character Codes in the resultant HTML. So adding the tag

data-0

to the section

g-mainbottom1

with the attribute

background-position: 50% 100px

results in this div:

<section id="g-mainbottom1" data-0="background-position&#x3A;&#x20;50&#x25;&#x20;100px&#x3B;">

rather than the desired

<section id="g-mainbottom1" data-0="background-position: 50% 100px;">

Assuming there's nothing I can do to prevent the conversion behaviour, is there anything I can do with the actual text to prevenmt these characters from being converted Unicode Hex equivalents?


回答1:


I think you forgot to use <meta charset="UTF-8"> in the <head> tag

<head>
    <meta charset="UTF-8">
    <meta name="description" content="Free Web tutorials">
    <meta name="keywords" content="HTML,CSS,XML,JavaScript">
    <meta name="author" content="John Doe">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>

Metadata is data (information) about data.

The tag provides metadata about the HTML document. Metadata will not be displayed on the page, but will be machine parsable.

Meta elements are typically used to specify page description, keywords, author of the document, last modified, and other metadata.

The metadata can be used by browsers (how to display content or reload page), search engines (keywords), or other web services.

HTML5 introduced a method to let web designers take control over the viewport (the user's visible area of a web page), through the tag (See "Setting The Viewport" example below).

reference https://www.w3schools.com/tags/tag_meta.asp



来源:https://stackoverflow.com/questions/53436369/characters-in-attributes-being-converted-to-unicode

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!