Simple HTML question

I

Ian Davies

I wish to refer to a line of HTML code without activating that code in my
documents. So, for example, if I want to describe the string of code needed
to make a link, I can do so without creating the link itself, rather than
the code. How is this acheived

Thanks
Ian
 
T

Toby Inkster

Ian said:
I wish to refer to a line of HTML code without activating that code in my
documents.

Try this:-

<p>Here is how you make something bold:
<code>&lt;b&gt;bold&lt;/b&gt;</code>.</p>
 
N

Neredbojias

To further the education of mankind, "Ian Davies"
I wish to refer to a line of HTML code without activating that code in
my documents. So, for example, if I want to describe the string of
code needed to make a link, I can do so without creating the link
itself, rather than the code. How is this acheived

Put the "code" in a <p> or something and escape the "<" with &lt; and the
">" with &gt;
 
M

Martin Jay

Ian Davies said:
I wish to refer to a line of HTML code without activating that code in my
documents. So, for example, if I want to describe the string of code needed
to make a link, I can do so without creating the link itself, rather than
the code. How is this acheived

Use:

&lt;a href="index.html"&gt;Index page&lt;/a&gt;

or, maybe:

&lt;a href=&quot;index.html&quot;&gt;Index page&lt;/a&gt;

instead of:

<a href="index.html">Index page</a>

For example &lt; instead of < and &gt; instead of >.

There's a list at:

<http://www.htmlhelp.com/reference/html40/entities/special.html>

And perhaps put your code between <code></code> or <pre></pre> HTML
tags. There's some info here:

<http://www.htmlcodetutorial.com/quicklist.html>
 
B

Blinky the Shark

Toby said:
Try this:-

<p>Here is how you make something bold:
<code>&lt;b&gt;bold&lt;/b&gt;</code>.</p>

It just occurred to me that it seems like "<code>foo</code>"
should make foo inert by definition. I mean, as part of the
design intent of "<code>" it seems like using that implies "this
is a representation of code, not code to be processsed here".

I hope that made sense; it was clear here. :)
 
I

Ian Davies

thanks all
thats solved it
ian

Martin Jay said:
Use:

&lt;a href="index.html"&gt;Index page&lt;/a&gt;

or, maybe:

&lt;a href=&quot;index.html&quot;&gt;Index page&lt;/a&gt;

instead of:

<a href="index.html">Index page</a>

For example &lt; instead of < and &gt; instead of >.

There's a list at:

<http://www.htmlhelp.com/reference/html40/entities/special.html>

And perhaps put your code between <code></code> or <pre></pre> HTML
tags. There's some info here:

<http://www.htmlcodetutorial.com/quicklist.html>
 
D

David Dorward

Blinky said:
It just occurred to me that it seems like "<code>foo</code>"
should make foo inert by definition. I mean, as part of the
design intent of "<code>" it seems like using that implies "this
is a representation of code, not code to be processsed here".

No, it just says that it is code. It is more than possible that an author
might want to give emphasis to part of it, or hyperlink sections (e.g. a
function call to a function definition), so it would be unhelpful for it to
prevent markup being processed.
 
T

Toby Inkster

Blinky said:
It just occurred to me that it seems like "<code>foo</code>"
should make foo inert by definition.

Do you mean that <code><b></code> should be equivalent to
<code>&lt;b&gt;</code>?

If so, they tried that with <xmp>, but that was deprecated as of HTML 4 as
it is impractical for many reasons:

- what if you actually want to include some bold text
within your code fragment (useful for syntax highlighting
for example)?
http://test.tobyinkster.co.uk/Preview/Syntax-Highlighting/test.php

- it makes parsing difficult

- it doesn't fit in nicely with SGML rules, making validation
tricky.
 
B

Blinky the Shark

Toby said:
Do you mean that <code><b></code> should be equivalent to
<code>&lt;b&gt;</code>?

I mean that something in the code element should not be operated
upon; it should just be displayed.
If so, they tried that with <xmp>, but that was deprecated as of
HTML 4 as it is impractical for many reasons:

- what if you actually want to include some bold text
within your code fragment (useful for syntax highlighting
for example)?

I guess you'd be out of luck.
http://test.tobyinkster.co.uk/Preview/Syntax- Highlighting/
test.php

- it makes parsing difficult
Why?

- it doesn't fit in nicely with SGML rules, making
validation
tricky.

I'll have to believe you on faith, there.
 
J

Jose

Except for browsers that don't support the code tag.
And which browsers might that be?

Older ones.

I don't have a list (nor do I really care), but it good design to design
standards that don't break in older browsers. That is the way I believe
HTML is set up - if a tag is unrecognized, it is ignored. A code tag
that is ignored leaves what's inside to be interpreted raw. So, what's
inside needs to be safe raw, and the code tag needs to take that into
account when it's interpreted.

Jose
 
J

Jonathan N. Little

Jose said:
Older ones.

I don't have a list (nor do I really care), but it good design to design
standards that don't break in older browsers. That is the way I believe
HTML is set up - if a tag is unrecognized, it is ignored. A code tag
that is ignored leaves what's inside to be interpreted raw. So, what's
inside needs to be safe raw, and the code tag needs to take that into
account when it's interpreted.

How old do you want to go here MSIE4.x and NN4.x recognize the tag and
their usage is less than 1/10 percent!
 
J

Jose

How old do you want to go here MSIE4.x and NN4.x recognize the tag and their usage is less than 1/10 percent!

When designing a compatible =standard=, you (or at least I would) go as
far back as time.

Jose
 
J

Jonathan N. Little

Jose said:
When designing a compatible =standard=, you (or at least I would) go as
far back as time.

So you never use a table, right? First IE didn't support them....be real
now!
 
J

Jose

So you never use a table, right? First IE didn't support them....be real now!

It's not a question of whether I use a whatever as a WEB designer, it's
a question of =how= to design the =standards= for a whatever, as a
STANDARDS designer.

And yes, in the earlier years (not too long ago actually) I had avoided
tables when possible so as to be useful in more browsers. I now use
tables (but don't like them much as a user because cut and paste don't
work well).

Were I to DESIGN the code tag, I would design it such that whatever was
inside the code tag would still be able to be marked up, because
browsers that do not support the code tag would present the content as
is, and I would expect the web designer to have the option of marking it
up appropriately for such a case.

Were I to USE the code tag, I would expect what's inside to be
interpreted as HTML and require escape codes to display characters that
would otherwise be "live".

Jose
 
I

ironcorona

Jose said:
Were I to DESIGN the code tag, I would design it such that whatever was
inside the code tag would still be able to be marked up, because
browsers that do not support the code tag would present the content as
is, and I would expect the web designer to have the option of marking it
up appropriately for such a case.

Were I to USE the code tag, I would expect what's inside to be
interpreted as HTML and require escape codes to display characters that
would otherwise be "live".

I disagree. What else, then, is the point of the <code> tag if not to
be used to display the exact content of the tag (as opposed to the
marked up version). People don't usually use scripts (or whatever) to
search through HTML documents to parse the contents of a <code> tag in
order to extract the code itself and since the tags are not meant to be
read by humans (after the browser gets hold of it) it seems weird that
you would have ANOTHER tag that sets out an area.

Most of those old tags should be depreciated because you can you the
"class" or "id" attribute to mark off specific areas, as per the ideal
of separating style from content: using <span> or <div> in conjunction
with CSS is just as useful.

<code> would be much more useful to show areas of plaintext which the
browser doesn't mark up.
 
J

Jonathan N. Little

Jose said:
It's not a question of whether I use a whatever as a WEB designer, it's
a question of =how= to design the =standards= for a whatever, as a
STANDARDS designer.

And yes, in the earlier years (not too long ago actually) I had avoided
tables when possible so as to be useful in more browsers. I now use
tables (but don't like them much as a user because cut and paste don't
work well).

Not use what you mean CODE element has be part of the markup repertoire
since 2.0 back in 94 so basically every graphical browser supports it.
12 years ago, thats eons in computer years!
Were I to DESIGN the code tag, I would design it such that whatever was
inside the code tag would still be able to be marked up, because
browsers that do not support the code tag would present the content as
is, and I would expect the web designer to have the option of marking it
up appropriately for such a case.

If the content is computer code then semantically it is proper to use
the CODE element. If it is a paragraph, use P. If is it a list, use UL
or OL. If the data is tabular then use a TABLE by all means. It would be
wrong really to put tabular data in a series of positioned DIVs
Were I to USE the code tag, I would expect what's inside to be
interpreted as HTML and require escape codes to display characters that
would otherwise be "live".

CODE element just denotes that the contained text is source code of some
sort and is usually displayed in a monospaced font. Nothing is escaped,
you still need html entities like &gt; and &lt;
 
D

David Dorward

ironcorona said:
I disagree. What else, then, is the point of the <code> tag if not to
be used to display the exact content of the tag

To state that the data being marked up is code (and thus to allow the user
agent to inform the user of the fact).
Most of those old tags should be depreciated because you can you the
"class" or "id" attribute to mark off specific areas, as per the ideal
of separating style from content: using <span> or <div> in conjunction
with CSS is just as useful.

"This section is text is some code" is not "style".
<code> would be much more useful to show areas of plaintext which the
browser doesn't mark up.

As mentioned previously, I often markup code that requires further markup
within the section of code.
 
I

ironcorona

David said:
To state that the data being marked up is code (and thus to allow the user
agent to inform the user of the fact).


"This section is text is some code" is not "style".


As mentioned previously, I often markup code that requires further markup
within the section of code.

Actually, I was coming back to delete that comment. I made a complete
arse of the argument. I was infact, arguing the wrong thing. Please ignore.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top