Is XHTML really format free?

D

Don Adams

Is XHTML really format free? Here's what I'm
struggling with...

I am switching my structured FrameMaker documentation from
docbook-based SGML to XHTML1.1-based XML.
In SGML, I used the following to define a section:

<section>
<title>Section Title</title>
<para>First paragraph under the section.</para>
</section>

This allowed me to nest sections and the format of
the heading (the <title> element) would change based on
the nested level of the section. For example, a <section>
nested under a parent <section> would use a second-level heading
format for the <title> element (using FrameMaker's EDD to
control the format -- similar to style sheets).

In XHTML1.1, I am using the following:

<div class="section">
<h1>Section Title</h1>
<p>First paragraph under the section.</p>
</div>

This still allows me to nest sections and the format of the
heading (the <h1> element) changes based on the nested level
of the <div class="section"> element. For example, a <div class="section">
nested under a parent <div class="section"> uses a second-level heading
format for the <h1> element (using stylesheets to control the format).

But, is this "proper" use of the <h1> XHTML element? If it is the
proper use, why have other heading elements (<h2>, <h3>, etc.) defined in
XHTML?
If it is not the proper use, how would you make the headings change based
on their nested level in the document structure?
(Note: changing all the <h3> elements to <h2> elements in a moved section
"by hand" is not an option.)

I understand the need/desire to have XHTML backward compatible with HTML,
but shouldn't a generic <h> element have been created to support format-free
XHTML?
 
D

Dean Tiegs

Don Adams said:
Is XHTML really format free?

I'm not sure what you mean by "format free". Do you mean "completely
lacking format"? That doesn't make sense.
In XHTML1.1, I am using the following:

<div class="section">
<h1>Section Title</h1>
<p>First paragraph under the section.</p>
</div>

This still allows me to nest sections and the format of the heading
(the <h1> element) changes based on the nested level of the <div
class="section"> element. For example, a <div class="section">
nested under a parent <div class="section"> uses a second-level
heading format for the <h1> element (using stylesheets to control
the format).

But, is this "proper" use of the <h1> XHTML element?

No. CSS style sheets are optional, and the user can override yours
with his, so you should design so that the XHTML structure is still
apparent without your author style sheets.
If it is not the proper use, how would you make the headings change
based on their nested level in the document structure? (Note:
changing all the <h3> elements to <h2> elements in a moved section
"by hand" is not an option.)

You could use an XSLT transformation that corrects the h1 ... h6
I understand the need/desire to have XHTML backward compatible with
HTML, but shouldn't a generic <h> element have been created to
support format-free XHTML?

It is proposed for XHTML 2.
 
D

Don Adams

I'm not sure what you mean by "format free". Do you mean "completely
lacking format"? That doesn't make sense.

What I mean is "structure" verses "format". (I probably should
have used the word "style" instead of "format"). To me, structure is
organization
of data and format is presentation of data. My philosophy is
that XHTML should contain structure only and formatting is done
with a stylesheet. However, the <h1> through <h6> elements
contradict this philosophy and, for me, are very difficult to deal with.

The reason <h1> - <h6> are difficult to deal with is that I need a way to
literally copy a
chunk of XHTML from one file, and paste it into another file and not have
to worry about changing <h3> elements to <h2>. The copy-and-paste
operation could be done with anything from a text editor to a
desktop publisher. I don't have control over how it's done, so I can't
write a program
to do the <h3> to <h2> conversion automatically.

My temporary solution is to make <h1> generic and format it
differently depending on what level it is in nested <div class="section">
elements. Like so:

<div class="section"><h1>text</h1></div> // This is a Level 1 heading

<div class="section">
<h1>text</h1> // This is a Level 1 heading
<div class="section">
<h1>text</h1> // This is a Level 2 heading
</div>
No. CSS style sheets are optional, and the user can override yours
with his, so you should design so that the XHTML structure is still
apparent without your author style sheets.

I agree, which is why I wanted to see if anyone else had
a better way. I thought about <p class="heading"> instead of <h1> but
then I loose all format if a stylesheet is not used.
 
U

Uwe Nowak

Don said:
The reason <h1> - <h6> are difficult to deal with is that I need a way to
literally copy a
chunk of XHTML from one file, and paste it into another file and not have
to worry about changing <h3> elements to <h2>. The copy-and-paste
operation could be done with anything from a text editor to a
desktop publisher. I don't have control over how it's done, so I can't
write a program
to do the <h3> to <h2> conversion automatically.

The W3C ist thinking about dropping h1 to h6 out of the stnadard xtml
2.0. (see working draft of XHTML 2.0 in W3C). In version 1.0 and 1.1
theses tags were included because otherwise xhtml documents would have
been incompatible to older standards.

So one single documents can be format free, just use h1 to h6 in the
right structure and define Layout with CSS. But you cannot preserve the
structure if you copy the document as an subsection of another document.

Good bye,
Uwe
 
T

True Gamer

What you should do instead of <h1> is <span class="whatever">. The span
element is for describing inline style and you should use <div> for
separate paragraphs like h1 can be used for. Just remember that if you
define a class and the user doesn't define that element or that class
that yours is used. You could even dump the dtd and make up your own
element to be generic. I use XHTML for designing websites. It is
important to make every site compatible with any browser. The only
problem with a made-up element is that I'm not sure that it works in
Netscape-compatible browsers though. You should get a
Netscape-compatible browser and a version of Internet Explorer and try
it on both. If you really need to have XHTML 2, you could make a DTD
and have parts of it look generic.
---------------------------------------------------------------------------
 

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

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top