Question

I have three files.

header.php
index.php
footer.php

The header file contains from <html> to <div id='content'> The index file contains page content The footer file contains </div> to </html> Together they contain a normal HTML file with PHP

When I use Tidy HTML to tidy up my php files' HTML, it does something wrong. When I tidy header.php, it adds closing tags to my div called content and it shouldn't. The div is continued through index.php and closed in footer.php to specify the content's of the file.

Is it possible to make HTML Tidy ignore missing end tags?

Was it helpful?

Solution

It can be solved this way:

<html>
<head>
  <?php include "head.php" ?>
</head>
<body>
  <?php include "header.php" ?>
  <?php include "index.php" ?>
  <?php include "footer.php" ?>
</body>
</html>

And the files index.php, head.php, header.php and footer.php now should have starting and closing tags. The program does that because it thinks you missed the closed tags. I saw Tidy HTML and it puts the close tags automatically.


Source: My experience doing sites this way

OTHER TIPS

Sounds like you need hide-endtags: yes in your config:

Type: Boolean
Default: no
Example: y/n, yes/no, t/f, true/false, 1/0  

This option specifies if Tidy should omit optional end-tags when generating the pretty printed markup. This option is ignored if you are outputting to XML.

According to the spec linked here, html and body start tags are also optional, and my Tidy removes those as well, which should be no problem. cfg file:

hide-endtags: yes // Don't add optional end tags. Also hides optional start tags like HTML and BODY.
tidy-mark: no  // Don't add generator meta tag.

However, it stilll closes div. This alternative suggested here works as intended.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top