View Full Version : Stop browser reading tags?
divtag33
09-29-2006, 02:21 PM
Hi how do you stop the browser reading tags?
ie if I wanted to write a tutorial on HTML I'd need to be able to tell people to write:
<p>Duck</p>
and not have it appear as Duck (ie have the <p> tags interpreted)
I've tried blockquote and pre tags, but no joy...:confused:
mburt
09-29-2006, 03:33 PM
Replace "<" with "<" and replace ">" with ">"
jscheuer1
09-29-2006, 05:31 PM
mburt is right, that is the correct way to do this but, sometimes that can get to be a bit tedious. I think this is invalid but, it works in most modern browsers:
<textarea cols="30" rows="5" style="border-width:0;font-family:sans-serif;">
<p>Duck</p>
</textarea>
If you allow enough rows and cols for the displayed content there should be no scrollbars and it will look like ordinary text - useful if you have a lot of content of this nature to display.
Or, you can just skip the style and have a textarea for your users to easily know they can select and copy from it.
Better:
<![CDATA[
<p>Duck</p>
]]>
mburt
09-29-2006, 06:46 PM
It would be wise to add 'readonly' to the textarea tag. You could make it like a normal div with some style:
<textarea readonly style="height:300px;width:500px;border:0px;overflow:hidden;font:12px arial"><p>The tags will appear here</p></textarea>
I'm not sure if that boolean shorthand is valid HTML Strict or not, but it's certainly not valid XHTML. For maximum portability, readonly="readonly" is preferable.
jscheuer1
09-29-2006, 07:58 PM
I'm not sure if that boolean shorthand is valid HTML Strict or not, but it's certainly not valid XHTML. For maximum portability, readonly="readonly" is preferable.
For HTML, readonly="readonly" is invalid. Or, at the very east, what you call shorthand is the preferred method. And, why worry about portability? Aren't you one of the ones going around telling people not to write XHTML unless it is XHTML?
mwinter
09-29-2006, 08:41 PM
I think this is invalid but, it works in most modern browsers:
<textarea cols="30" rows="5" style="border-width:0;font-family:sans-serif;">
<p>Duck</p>
</textarea>
Yes, it is.
To avoid the tediousness, one could just use a region-limited search and replace operation. Any good text editor should be capable of it.
Better:
<![CDATA[ <p>Duck</p> ]]>
In theory, but not in practice unless one is serving an application of SGML or XML to be processed as SGML or XML (for which neither HTML nor XHTML as HTML qualifies).
I'm not sure if that boolean shorthand is valid HTML Strict or not
The document type doesn't matter, and it is valid.
For maximum portability, readonly="readonly" is preferable.
The recommendation has been to the contrary, though it may not be quite as significant as it once was.
For HTML, readonly="readonly" is invalid.
Not at all. The readonly attribute has only one value: readonly.
See towards the end of section 3.3.4 Attribute declarations (http://www.w3.org/TR/html4/intro/sgmltut.html#h-3.3.4.2) and appendix B.3.4 Boolean attributes (http://www.w3.org/TR/html4/appendix/notes.html#h-B.3.4) for more information on boolean attributes.
Mike
And, why worry about portability? Aren't you one of the ones going around telling people not to write XHTML unless it is XHTML?That doesn't mean that it's wrong to use something that's valid in XHTML if it's also valid HTML :) While there's no downside, there's no real reason not to do so.
The recommendation has been to the contraryWhy so?
djr33
09-29-2006, 10:05 PM
Another simple answer... if you're using dreamweaver or any other html wysiwyg editor, just copy and paste the code into the preview view.
That will automatically convert for you.
Then go to the code, and cut/paste that, and it will have the > and < tags all done for you.
jscheuer1
09-30-2006, 02:39 AM
The document type doesn't matter, and it is valid.
For maximum portability, readonly="readonly" is preferable.
The recommendation has been to the contrary, though it may not be quite as significant as it once was.
For HTML, readonly="readonly" is invalid.
Not at all. The readonly attribute has only one value: readonly.
For HTML, readonly="readonly" is invalid. Or, at the very (l)east, what you call shorthand is the preferred method.
I still get a little miffed when what I have written is taken out of context but, I'm getting used to it and, as these things go, this wasn't one of the worst cases.
mwinter
09-30-2006, 12:15 PM
[Using full, rather than minimised attributes] The recommendation has been to the contrary
Why so?
Historically, browser support has been poor for non-minimised boolean attributes. Why else?
I still get a little miffed when what I have written is taken out of context ...
Your statement wasn't taken out of context. You raised doubt about the validity of a particular construct, just as Twey did. The sentence that followed had no relevance in that regard, so there was no point in quoting it.
Mike
jscheuer1
09-30-2006, 03:26 PM
Your statement wasn't taken out of context.
Well, it was, and as I said, not in such a bad way in this particular case.
The main point is that what I said following that, sums up the situation.
mburt
09-30-2006, 08:15 PM
Holy crap... All this err... "fuss", over whether readonly is a boolean attribute, or if it's valid or not. I think the point has been settled, and that this is unnecessary.
jscheuer1
10-01-2006, 01:20 AM
Holy crap... All this err... "fuss", over whether readonly is a boolean attribute, or if it's valid or not. I think the point has been settled, and that this is unnecessary.
As it doesn't affect you, that's correct, you needn't concern yourself with it. I still like to point out when I am taken out of context, most people would, I think. I am generally happy to admit when I have made an error. By the same token, I don't like being misquoted into appearing to have made one when I have not. My remarks in this thread in regards to that were not directed at you, mburt. Please accept my apologies if they caused you any distress.
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.