I want to some sample code in a html page. How do I do it, for example I want to show a tag and image tag, in stackoverflow I use 4 spaces:
A Tag example:
<a href="your_url"></a>
Image Tag example:
<img...>
The <q> HTML element indicates that the enclosed text is a short inline quotation. Most modern browsers implement this by surrounding the text in quotation marks. This element is intended for short quotations that don't require paragraph breaks; for long quotations use the <blockquote> element.
q can only contain phrasing content (and it can only be used where such phrasing content is expected). blockquote can only contain flow content (and it can only be used where such flow content is expected).
HTML <blockquote> tag is used to define a block of text which is quoted from another source. The Browser usually displays the content within <blockquote> tag as indented text. If you want to insert a long quote then use <blockquote> and for short or inline quote use <q> tag.
Can I use single quotes in HTML? Yes, you can! make sure to use either double quotes to wrap your values or escape the single quotes using ' .
To format the output, you can use the pre element.
Howver, you will still need to turn the special characters <
>
'
"
&
into their HTML entities <
>
and so on so the HTML tags turn up in clear text and don't get rendered by the browser.
If you can use PHP, there is htmlspecialchars() for that. Every server-side scripting language has an equivalent of it.
In JavaScript, setting the innerText
property of the pre
container leads to the characters being displayed literally and not as interpreted HTML.
If you want to do it manually, this is what you need to convert:
& to &
> to >
< to <
" to "
' to '
source
I think you're asking for the <pre>
tag for preformatted text.
Everything that goes inside the pre tag it's not interpreted.
Try this on a browser:
<pre>
<img src="whatever" />
<othertag>whatever</otherta>
</pre>
EDIT: As Pekka pointed out, for HTML tags, symbols must be converted to their HTML entities.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With