line breaks and indentation in html output

Jarkoza

New Member
Recently I was printing out some HTML source for a project I've been working on. I like to keep my markup tidy and readable. I noticed that in some places there are no line breaks on the outputted html and in some places there is excess indentation. For example take the following code, where I have preserved the indentation from the source file:\[code\] <div id="sections"> <ul> <?php if(!empty($details)) { ?> <li><a href="http://stackoverflow.com/questions/3901502/#details"><span>Details</span></a></li> <?php } if(!empty($address) { ?> <li><a href="http://stackoverflow.com/questions/3901502/#viewmap"><span>Location Map</span></a></li> <?php } if(!empty($reviews) { ?> <li><a href="http://stackoverflow.com/questions/3901502/#reviews"><span>Reviews (<?php echo $numrows; ?>)</span></a></li> <?php } if($email != null) { ?> <li><a href="http://stackoverflow.com/questions/3901502/#sendemail"><span>Send an Email</span></a></li> <?php } ?> </ul>\[/code\]The generated HTML output is as follows:\[code\] <div id="sections"> <ul> <li><a href="http://stackoverflow.com/questions/3901502/#details"><span>Details</span></a></li> <li><a href="http://stackoverflow.com/questions/3901502/#viewmap"><span>Location Map</span></a></li> <li><a href="http://stackoverflow.com/questions/3901502/#sendemail"><span>Send an Email</span></a></li> </ul> </div>\[/code\]Here we can see the DIV and UL tags have two tab indents from the left - this is fine. However the LI tags have 5 indents from the left - it should only be 3 if it goes according to my code. The end UL tag also has two extra indents.Is this just the expected behaviour or can this be rectified somehow?
 
Back
Top