I have documents with lots of font-awesome icons in them, which are embedded using <i class='icon-somename'></i>
. An empty i tag... HTML Tidy removes them. I've set drop-empty-paras
to false, but it still removes this tag. The documentation has not been of any help in resolving the matter, perhaps someone here knows?
I think it's absurd to have to break all my icons by adding content inside the tag just so tidy can be run then remove all the content again afterwards. But so far that has been the only suggestion I've found.
Click in the tab "Logical Structure" on the button "Delete Empty Tags". Select which kind of empty tags shall be deleted. Confirm by clicking the button "OK". Done!
Empty: An element that contains no data but, rather, is an instruction to the browser to perform some action, such as force a line break or display an image. Empty elements in XHTML are terminated with a trailing slash, as in <br /> . Non-empty: An element that contains data.
The tags that do not contain any closing tags are known as empty tags. Empty tags contain only the opening tag but they perform some action in the webpage. Syntax: <tag_name>
Empty tags are also known as void or unpaired tags.
I had the same problem in the Tidy2 plugin for Notapad++. It was removing some empty tags that had nothing but a bootstrap class on them, like <span class="caret"></span>
. I fixed it by using drop-empty-elements: no
in the config file.
This is an old question, and the documentation you linked to doesn't show that option as being valid, so probably you were using original Tidy and the option was added in Tidy2.
Just figured, since my initial search landed me here, and I didn't find the answer on this post and had to figure it out myself, maybe this answer will help someone else, even if it's too late to help the OP.
try:
tidy.setTrimEmptyElements(false);
If using it from a CLI environment you can override the config :tidy --drop-empty-elements no "/path/to/file.html"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With