Question

My code looks like that

<?php
ob_start();
?>
....
Some HTML
...
<div class="ui-state-error ui-corner-all" style="padding: 0 .7em;"> 
                    <p><span class="ui-icon ui-icon-alert" style="float: left; margin-right: .3em;"></span> 
                    <strong>Alert:</strong> Sample ui-state-error style.</p>
                </div>
  ....
Some HTML
...  
<?php
$markup = ob_get_clean();

// Specify configuration
$config = array(
    'indent' => true,
    'output-xhtml' => true,
    'wrap' => 200);

// Tidy
$tidy = new tidy;
$tidy->parseString($markup, $config, 'utf8');
$tidy->cleanRepair();

// Output
echo $tidy;
?>

Getting result without <span class="ui-icon ui-icon-alert" style="float: left; margin-right: .3em;"></span>. What am I missing? Maybe TIDY class removing empty tags? If yes, How can I prevent it?

Was it helpful?

Solution

I posted a comment: "Have you tried adding &nbsp; or some text inside the span to be sure that is removed because it's empty?". And it seems that &nbsp; worked.

So if somebody has the same problem and comes here, the solution is:

Add &nbsp; inside the empty element.

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