im looking for a way to show html as html without the browser reading it,
i found <plainttext> but once i start it i can't stop it
for example:
<plaintext>
<span> dobeediedabiedadadee olleeeeee</span>
</plaintext>
<h1>hi</h1>
in this example the span had to be shown as text and the h1 as a header, but the output is:
<span> dobeediedabiedadadee olleeeeee</span>
</plaintext>
<h1>hi</h1>
</body>
</html>
here a JSFiddle link:
JSFiddle
a other solution as plaintext is also welcome
thanks for your time.
plaintext has long been deprecated, just use > and <
<span> dobeediedabiedadadee olleeeeee</span>
DEMO: Fiddle
You could always use javascript to escape the HTML. Here is a fiddle.
html.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
The following link describes the difficulty in using <plaintext>. long story short it is not fully supported in any browser and you should be using <pre> instead.
http://reference.sitepoint.com/html/plaintext
<plaintext> is not a pair tag. From that tag to the rest of the page, everything is interpreted as text. However, this is not standard and obsolette in HTML5:
Examples
No, really. don't use it.
It is literally written in the w3 reference
Use PRE
<pre>
<span> dobeediedabiedadadee olleeeeee</span>
</pre>
<h1>hi</h1>
it is compatibility issue some browser completely ignores coding of
have a look at this link http://reference.sitepoint.com/html/plaintext
i would suggest you use instead
Related
How do you write <p></p> so that it can be displayed as text in an HTML page, rather than be interpreted as HTML (which would give an empty paragraph).
If you want to show the in the view,
Because, when you type that inside html element, it may be getting it as the html element itself.
if your purpose is showing that in the view just try this.
<p> </p>
Check this snippet :
<p> </p>
you can do it with using span
<span> < </span> <span>p</span> > <span> < </span> / <span>p</span><span> > </span>
or you can do below like this
<p> </p>
A P tag should print out text on your site no matter what. However, on most occasions you will need to refresh (F5) your page in order for it to take effect. Furthermore, if you got anything on your site that could be covering it up, try removing it just to see whether another element is "eating it up" or not. For example, try removing a banner image if thats something you got, or a navbar.
Usage for P, just in case:
<p> Text goes here </p>
Use Html entities to display the reserved html symbol
HTML Entities
this is what you mean? sorry if i understand wrongly but your description is very short.
View the source of this page. It managed it!
<p><\p>
and the answer was <p><\p>
so I have a strange request. I've been working on some security project for school, and I've been able to successfully inject some html code using a form on our test site. What's interesting is that it only accepts the html code as one line and with no spaces. This brings me to my question, so far I've only been able to get text and font color changes to work. But I want to see if someone could inject images/audio/video.
I'm trying to figure out how to turn this:
<img src="http://www.rtur.net/blog/image.axd?picture=2011%2F12%2Fcss.png"/>
Into this:
<imgsrc="http://www.rtur.net/blog/image.axd?picture=2011%2F12%2Fcss.png"/>
but add a space with code.
I've tried adding the but that only works with actualy text and not the tag itself. Any help is appreciated.
Interesting note: I was able to inject <font size="50" color="red"></font>
But I have no idea why that works but the image doesn't.
Have you tried the following?
A slash:
<img\ src="http://www.rtur.net/blog/image.axd?picture=2011%2F12%2Fcss.png"/>
Using a non-traditional closing tag:
<img src="http://www.rtur.net/blog/image.axd?picture=2011%2F12%2Fcss.png"></img>
Injecting a blank <img> tag:
<img src=""/>
Here's another solution: Try inline CSS:
<div style="background:url(http://www.rtur.net/blog/image.axd?picture=2011%2F12%2Fcss.png);height:400px;width:400px"></div>
See this fiddle: http://jsfiddle.net/9MYrM/
I am working on a how-to and I want to show on the user's screen the line like this:
Example: <div class="something>Example</div>
Obviously, the browser will render it as an actual div so how do I display it as just text?
<div class="something>Example</div>
HTML encoding
Use the code for less than or greater than: < and >
<div class="something">Example</div>
Selecting the said text in Stack Overflow, and viewing the selection source, the source for your code block is
<code><div class="something>Example</div></code>
in Stack overflow...
try this:
< div > Your things here </div >
You can use CDATA to display code: <![CDATA[Your <code> here]]>
This may not work with all browsers.
This is a very strange problem I've been struggling with for a few days. At first I thought it was related to something in our application, but I've stripped it down to the simplest html page and it's still happening. Basically anytime I add a tag to a page the html after it gets rendered as it's value. <textarea></textarea> fixes the issue, but I don't understand why. I'm at a loss here, it has to be something really simple that I just don't know.
In the following example the paragraph tags show up as the value of the textarea.
I'm using IE8.
<html>
<head>
<title>About</title>
</head>
<body>
<textarea/>
<p align="center">
test
</p>
<p align="left">
test
</p>
</body>
<textarea> is not a self-closing tag. It should be re-written as <textarea></textarea>
I am assuming you trying to have the paragraphs appear after the textarea. Try not using the textarea tag as an empty tag.
<textarea></textarea>
<p align="center">
test
</p>
<p align="left">
test
</p>
I believe Textarea requires an opening and closing tag - at least that's how it's presented here:
textarea at w3schools
I had this problem too. I realized I had forgotten to give a name attribute to my textarea like I did all my other inputs so that the PHP script could collect it all and send it to an SQL table.
Once I gave it a name, it magically stopped chopping off the closing tag and making it a self closing tag which got ignored by the browser until it bumped into the closing tag of a textarea with a name attribute, swallowing up everything in between. Hopefully this sheds more light on the issue too, as putting text in between the closing tags wasn't an ideal option for me.
The text in my source code is formatted properly, but when it shows up in the browser all the formatting disappears. Is there a tag I could add to the paragraph tag to make the text properly format?
you could use the <pre> and </pre> tags to preserve formatting instead of the <p> tag
The <pre> tag sounds like what you need.
<div style="white-space:pre">
hereIsSomeSourceCode();
if (blah == 3)
doSomething();
</div>