Is it possible to use an <a> tag within a <pre> tag?

隐身守侯 提交于 2019-12-07 07:53:29

问题


Im working with some legacy code that generates a given message on a webpage but surrounds it with a <pre> tag - I was hoping to put a link (anchor tags) within it like this:

<pre>User created successfully - <a href='/View/User/17'>click here</a> to view the users profile</pre>

But I think because its a <pre> tag it ignores tags within it. Is there any way around this?

APOLOGIES

Im really sorry to have wasted everyone's time - the reason why it was happening was due to the fact that I was using ModelState.AddModelError (in ASP.NET MVC) to set the error message, which automatically HTML encodes the message you give it (I used Chrome's element inspector which shows the HTML decoded version, hence the confusion)


回答1:


Phrasing content (such as <a>) is allowed in <pre>.

References:

  • W3C: The <pre> element


来源:https://stackoverflow.com/questions/13841386/is-it-possible-to-use-an-a-tag-within-a-pre-tag

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