chuang4630
asked on
HTML displaying rich text (html format)
I have a HTML5 file such as :
<div>Value= @item.Description</div>
<div>Hardcode=<p><strong>F irst Item of Group A-0 description</strong></p><u l><li>Firs t line</li><li>Second line</li></ul><p>-- END --</p><p>
</div>
The value of @item.Description is: =<p><strong>First Item of Group A-0 description</strong></p><u l><li>Firs t line</li><li>Second line</li></ul><p>-- END --</p><p>
The output:
Value=<p><strong>First Item of Group A-0 description</strong></p><u l><li>Firs t line</li><li>Second line</li></ul><p>-- END --</p><p>
Hardcode=
First Item of Group A-0 description
First line
Second line
-- END --
How do I resolve this to display:
Value=
First Item of Group A-0 description
First line
Second line
-- END --
<div>Value= @item.Description</div>
<div>Hardcode=<p><strong>F
</div>
The value of @item.Description is: =<p><strong>First Item of Group A-0 description</strong></p><u
The output:
Value=<p><strong>First Item of Group A-0 description</strong></p><u
Hardcode=
First Item of Group A-0 description
First line
Second line
-- END --
How do I resolve this to display:
Value=
First Item of Group A-0 description
First line
Second line
-- END --
i am lost :) screenshots please...
ASKER
I have attached the screen capture
html01.PNG
html01.PNG
ASKER
Here is the code:
<div>Value=@Item.Descripti on</div>
<div>Hardcode=<p><strong>F irst Item of Group A-0 description</strong></p><u l><li>Firs t line</li><li>Second line</li></ul><p>-- END --</p><p></div>
<div>Value=@Item.Descripti
<div>Hardcode=<p><strong>F
ASKER
Here is the screen shots of the rendered html (from Inspect element)
html02.PNG
html02.PNG
shooting in the dark :)
<div>
Value=
<p><strong>First Item of Group A-0 description</strong></p>
<ul><li>First line</li><li>Second line</li></ul>
<p>-- END --</p>
</div>
did you try to use surround it with <pre> tag
ASKER
I have tried.
<pre>@Item.Description</pr e>.
But there is no change. Basically, the html5 treats the value of @Item.Description as string, so it puts " " on the output (see it in the screenshots). What it should do is to display the innerHTML. But I do not know how to do it in the HTML. This is a small snippet in the @foreach loop. I would like to do it in the HTML, so it is readable.
How do I force browser to treat the value of @Item.Description as HTML markup, NOT the string?
<pre>@Item.Description</pr
But there is no change. Basically, the html5 treats the value of @Item.Description as string, so it puts " " on the output (see it in the screenshots). What it should do is to display the innerHTML. But I do not know how to do it in the HTML. This is a small snippet in the @foreach loop. I would like to do it in the HTML, so it is readable.
How do I force browser to treat the value of @Item.Description as HTML markup, NOT the string?
i dont see what you post here...
here is html5 file... save it to html file and open, you will not see what you posted...
post your code, not rendered html, or post view source, not from inspector...
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Title of the document</title>
</head>
<body>
<div>Value= @item.Description</div>
<div>Hardcode=<p><strong>First Item of Group A-0 description</strong></p><ul><li>First line</li><li>Second line</li></ul><p>-- END --</p><p>
</div>
The value of @item.Description is: =<p><strong>First Item of Group A-0 description</strong></p><ul><li>First line</li><li>Second line</li></ul><p>-- END --</p><p>
</body>
</html>
here is html5 file... save it to html file and open, you will not see what you posted...
post your code, not rendered html, or post view source, not from inspector...
ASKER
I am working on the MVC project. So the @item.Description is the value from the model. It is a html markup.
However, when I display it, it shows the markup language, instead of the rendered html:
<div>Value= @item.Description</div>
For example, <li>First line</li>. It display as straight string "<li>First line</li>". What I want is the rendered version of the it.
If you look at the "view source", you will see :
<div> "<li>First line</li>"</div>
Pay attention to the quotation mark, that forces the browser to treat it as a string. That is wrong. How do I fix it?
However, when I display it, it shows the markup language, instead of the rendered html:
<div>Value= @item.Description</div>
For example, <li>First line</li>. It display as straight string "<li>First line</li>". What I want is the rendered version of the it.
If you look at the "view source", you will see :
<div> "<li>First line</li>"</div>
Pay attention to the quotation mark, that forces the browser to treat it as a string. That is wrong. How do I fix it?
even this one
<div>"<li>First line</li>"</div>
looks ok in browser! like this:
or this
<div>"<li>First line</li>"</div>
looks ok in browser! like this:
"
* First Line"
or this
"
* First Line
"
please post full html rendered... and/or code that produces it...
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.