Re: HTML heading hierarchy for XHTML [RE-POST]

On Mon, 31 Jan 2000, Marc Rubin, Jay's Island Software Development &
Consulting wrote:

> I'd like to preserve the implicit hierarchy of HTML headings when
converting to XHTML. For example, I'd like to end up with this XHTML
output:
>
> <h1>Heading 1 text
>         <h2>Heading 2 under heading 1</h2>>
> given this HTML input:
>
> <h1>Heading 1 text</h1>> Would this translation be feasible as an option in Tidy?
Actually, this has nothing to do with Tidy but with the language.
heading elements are nothing but paragraph like elements with default
display options (sort of shortcuts) . They don't have nor implicit neither
explicit hierarchy.
They could be replaced by something like
<p class="heading1">, the class being processed at display by CSS (for
example)
So, you can't include a paragraph in a paragrah and you can't include a
header in a header.
Another way to solve this would be to use div elements and display header
in a
way according to the depth of the inclusion (using CSS).

<div>
  <p class="heading">Heading 1</p>    <p class="heading">Heading 2/</p>  </div>
</div>

CSS :
/* element h1 */
div p.heading {
  font-size:
  }
/* element h2 */
div div p.heading {
  ...
  }

/* element hn */
div div ... div p.heading {
  ...
  }

The superiority of this is that the appearance of the header is not
hardcoded but "computed", and that if you move a division, there is no
need to recode the headers.

Hope this helps

Received on Friday, 24 March 2000 13:14:54 UTC