简体   繁体   English

资源文件中的HTML标记显示为纯文本

[英]HTML Tags in Resource File Showing as Plain Text

I'm trying to bold a few words in a "Consent" string stored in a resource file to be displayed in a read-only, scrollable textbox on a web page. 我正在尝试将存储在资源文件中的“同意”字符串中的几个单词加粗,以显示在网页上的只读,可滚动文本框中。 I tried putting in the bold tags-- <b></b> -- but they would show up as plain text in the "Consent" string when the web page is run. 我尝试放入粗体标签<b></b> ,但是在运行网页时,它们将以纯文本形式显示在“同意”字符串中。

Since there were other strings stored in the same resource file using the break tag-- <br /> -- I thought I would try putting one in this "Consent" string. 由于使用break标记将其他字符串存储在同一资源文件中- <br /> -我想我将尝试在此“同意”字符串中放入一个。 This break tag, that works and inserts a new line for all the other strings in the same resource file, shows up as plain text again in this "Consent" string. 这个break标记可以在同一资源文件中为所有其他字符串插入新行,并在该“ Consent”字符串中再次显示为纯文本。

I thought it may be a css style override, but I don't think there is a css class referring to the textbox containing this string. 我认为这可能是css样式的替代,但是我不认为有css类指向包含此字符串的文本框。

This is a split view of the textbox containing the "Consent" string 这是包含“同意”字符串的文本框的拆分视图

This is a part of the "Consent" string I tried to bold: We are collecting responses to this assessment for <b>research purposes only</b>. 这是我试图粗体显示的“同意”字符串的一部分: We are collecting responses to this assessment for <b>research purposes only</b>.

ps. PS。 this is someone else's code that I was given to manipulate and learn from. 这是别人提供给我的代码,可以用来操作和学习。

Assuming your text box is an <input> or <textarea> , this is expected behavior - these elements don't support rich content out of the box. 假设您的文本框是<input><textarea> ,这是预期的行为-这些元素不支持框外的丰富内容。 You likely want to change that to a <div> or <span> with a height and width set to that of your expected text box dimensions, probably with overflow: auto; 您可能希望将其更改为高度和宽度设置为您期望的文本框尺寸的高度的<div><span> ,可能带有overflow: auto; so it will still show scroll bars if the content goes beyond its set height and width. 因此,如果内容超出其设置的高度和宽度,它将仍然显示滚动条。 It can also be styled with the appropriate background/border/etc. 也可以使用适当的背景/边框/等来设置样式。 to look like a text box. 看起来像一个文本框。

Alternatively, if you are trying to make the entire element bold, you can style the element such (eg setting font-weight: bold; on it). 或者,如果您尝试使整个元素变为粗体,则可以对元素进行样式设置(例如font-weight: bold;在其上设置font-weight: bold; )。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM