Home > OS >  Not recognizing <strong> tag in @Html.Raw in ASP.NET MVC C#
Not recognizing <strong> tag in @Html.Raw in ASP.NET MVC C#

Time:07-28

I am using ASP.NET MVC, when I want to use the tag in @Html.Raw, this tag does not appear in the desired <div>.

As shown here:

<div >
    @Html.Raw("<strong>OKK</strong> <p><ul><li style='font-size:18px;'>1.Test1</li><li>2.Test2</li></p>")
</div>

The result that it displays for me is as below, that is, it does not recognize the <strong> tag at all.

enter image description here

CodePudding user response:

Html.Raw does not interpret anything at all. It just spews the given string unencoded into the output docuument.

So if it doesn't look right in your case, possible you have some CSS in that page that causes it to look as it does. You could use F12 (Developer Tools, depending on your browser) to inspect the "OKK" for details.

BTW, the other tags in your example also look wrong (which could also be an issue given existing CSS in the page).

In my case, for example, using some (other) arbitrary styles, your code looks like this:

enter image description here

  • Related