do tags go inside or outside of tags?

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

  •   Subject
  • Author
  • Posted on

Hello. I've heard that <em> tags should go inside <p> tags rather than
outside, but what about <a> tags? Which is correct (I've found both in
the page I'm working on):

<em><a href="">blah</a></em>
<a href=""><em>blah</em></a>?

What if only part of the content is emphasized? This occurs in some of
the hyperlinks in the page I'm working on:
<a href=""><em>Some text</em> Some more unemphasized text</a>

To be consistent then, should I always use the <em> tags inside the
<a> tags? Sorry if these are dunderhead questions.

As for my last post, I am busily removing manual line breaks from all
the <dd>. It'll take a while yet to finish, but it's coming along. I'm
on the letter G now of the alphabet of that glossary.

Re: do tags go inside or outside of tags?

On 6 July, 11:04, TheBicyclingGuitarist
Quoted text here. Click to load it

Neither. It's probably time you learned how this really works.

You'll need to start dipping into the DTD

Tags go in places that tags are allowed. This is defined in the DTD,
where a group of tags are declared to be the "%inline;" group, another
the "%block;" group.  Other places (such as inside each tag) declares
what content is acceptable at a particular location, usually by
specifying this to be either %inline; or %block;    Where %inline;
content is permissible, you can use any of the content that was
declared as belonging within %inline;, but nothing else.

Nowhere does it define "<em> can be placed within <a>", or at least
only indirectly, via this two-part route. As there are many tags, it
would be impractical  to list each one's acceptable content tag-by-
tag, and so this grouped content model is used.

%inline; also includes #PCDATA, but %block; doesn't. So no bare text
in a %block;-only context.

In fact, there are three content models. A third, %flow; simply
represents the union of %block; and %inline;, i.e. tags from either
may be used there.  %block; is rarely specified in isolation, in most
cases it's %flow; so that you can use tags from either set (or
#PCDATA). Notably though, <body> in HTML Strict only accepts %block;
and not %inline;  (also <form>, <blockquote> and a few others).

So what about your tags? <em>, <a>, <p> all accept %inline; as their
content, but not %block;  <em> & <a> are defined as being members of
%inline; too, but <p> is part of %block;   This means that <em> & <a>
may be nested in any combination, but  while <p> can contain them, it
can't be placed inside either these, or inside another <p>.

In general, most commonly-used tags are either %block; and may contain
%flow;, or they're %inline; and may contain %inline;  <p> is an
exception (%block; outside, %inline; inside) and <body> as mentioned

Re: do tags go inside or outside of tags?

Andy Dingley wrote:

Quoted text here. Click to load it

It's a small difference, but my mathematical education prevents me from
calling it infinitesimal, just as it restricts my use of "infinite".

But I'm not sure whether there _is_ a semantic difference. At least there is
no _well-defined_ difference in HTML specifications.

Quoted text here. Click to load it

That's a reasonable interpretation of the semantic difference, but it's
really reasoning rather than something explicit in specifications. In most
cases, emphasizing a link can hardly be distinguished from emphasizing the
link text. But we might think that normally it's the link (and thereby
indirectly the linked resource) that is being emphasized, rather than the
text you happen to use as link text.

I'm happy that this conclusion - preferring <em><a> - is the same that I
have drawn on very different, rather practical grounds. I think it is quite
imaginable, and often sensible, to use a color other than normal text color
to render an <em> element, in addition to (or maybe even instead of) other
visual emphasis. Now, if you set color for <em> and you have <a><em>
nesting, then this color will kill the normal color variation between
unvisited, visited, and maybe hovered, focused, and active links. If you use
<em><a> nesting instead, the link text will get its color according to rules
for links, and this is better usability.

It probably pays off to be consistent. If you have mixed <em><a> and
<a><em>, there will be unnecessary trouble in styling.


Re: do tags go inside or outside of tags?

Quoted text here. Click to load it

To seek truth, one might sensibly go to an encyclopaedia; to
seek meaning, a dictionary. The encyclopaedia tends not to
deal with meaning directly, neither does the dictionary deal
in truth directly.

So, what is the connection? A crucial part of the idea of
'meaning' is the idea of 'same meaning'. Dictionaries are
built (very roughly) on this connection. You cannot
understand what something means if you cannot understand
that something else means the same thing. Not just things
like 'bachelor' and 'unmarried man' but 'bachelor' and
'bachelor' as said at different times and in different
contexts. Sameness of meaning is impossible to logically
divorce from our understanding of meaning.

Meaning depends on truth in that, for example, if 'bachelor'
means 'unmarried man' then any true sentence that has the
one term remains true on substituting the other term. If
meaning is constant between days and I say on one day that
all bachelors go bald earlier than married men, and I say on
another day that all bachelors go bald earlier than married
men, the words I use on one day likely have the same meaning
as on the other day. The important point is that it is not a
mere coincidence that if I speak truly on one day, I also
speak truly on another day. It is a logical necessity.
Roughly this means that truth and meaning are not totally
independent concepts.

And, conversely, truth crucially depends on meaning in that
if you change the meanings of the words in a sentence, you
can change the truth, the truth depends on the meaning of
the words.

Quoted text here. Click to load it

OK, let's look at commands, exclamations, questions. Of
course, these are not true or false and yes, they are
meaningful. However notice that truth nevertheless enters
into the question of the meaning.

If I am wondering what the meaning of the words in a
question asked by X are or what the whole question somehow
means I might try to paraphrase it and if the answer is yes,
that is the question, there is generated a couple of truths:

1. X asked "question"

2. X asked "question paraphrased"

If I get the paraphrase right, the truth of 1 and 2 fall or
fail together. If I get it wrong, they don't. It is not a
mere coincidence that truth goes with same meaning.

Quoted text here. Click to load it

To tell the truth, I have never liked the use of the word
semantics in HTML discussions but go along with it because
of weakness of character. These HTML elements have a
functional purpose, if we must identify this with semantics,
I suuuuuppppposssse we can stretch the term. A P is an
element whose purpose is to hold a paragraph, I don't like
the idea that it itself means paragraph or anything in
particular. What does a soccer ball mean? What does a
front-row balcony seat at the Opera mean? What does a
maximum-security cell in prison mean?


Re: do tags go inside or outside of tags?

Quoted text here. Click to load it

My light hearted remark was more a protest against the likely
vague confusion that the word semantics conjures up.

"<p>...</p>" does not mean paragraph in the way that "paragraph"
means paragraph. It is a container in which to put words that are
meant as a paragraph on the understanding that the browsers will
use presentation to convey the contents as a paragraph to humans.

On web pages, it is *presentation* that gives meaning to humans
because of long traditions of association of what certain looks
and sounds mean, the markup elements are instructions to browsers
to present things in the paragraph looking or sounding way.

So I have a different picture of this matter, Osmo. I would not
want to say that "semantics translates to non-presentational". I
would want to say, if we insist on the word semantics, that it
translates to (is a trigger for) a human reconizable

A user sees or hears only how the page looks or sounds, he does
not see any markup or any spooky anything (except in Luigi's

Mark-up, you might agree, is not a language that is meant to
speak to human web page visitors, it is more an instruction set
to devices like browsers.

What makes it meaningy or semanticy is that there are standards

1. What a page maker should use a paragraph element for is
understood and

2. What a browser maker should make the words in a paragraph look
or sound like is understood.

More or less. I am not strongly objecting to identifying meaning
in markup if it is somehow shorthand for these things I am raving
in a typical usenet fashion about.


Site Timeline