View Single Post
Old 08-08-2024, 04:54 PM   #11
Quoth
Still reading
Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.Quoth ought to be getting tired of karma fortunes by now.
 
Quoth's Avatar
 
Posts: 14,349
Karma: 105899727
Join Date: Jun 2017
Location: Ireland
Device: All 4 Kinds: epub eink, Kindle, android eink, NxtPaper
Quote:
Originally Posted by ptm@xact.co.uk View Post
Simply by parsing and committing an xhtml file, using the container, I see the following changes to the content.

Before parsing:
<span x="y"/>
<div id="w"/>

After committing:
<span x="y"></span>
<div id="w"></div>

Is there a 'tweak' setting or other method I can use to preserve the compact version of for tags with only attributes and no content?
It's only historic accident that regular content tags can be self closing.

First line before opening <html>
<?xml version='1.0' encoding='utf-8'?>
Only inside <head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<meta otherstuff />
<link rel="stylesheet" type="text/css" href="stylesheet.css"/>
</head
Inside the <body >
Valid tags for ebooks that are self closing:

<hr />
<br />

<img src="whatever" alt="sometext"> and height & width should be via a class.
maybe <col /> to set properties of a table column, but tables in ebooks are tricky
</body>

An ebook isn't a web page, nor an XML application for a browser.

Such a setting in general is crazy.
These are not converted self closing tags, but tags with no content.
Code:
<span x="y"></span>
	<div id="w"></div>
This is obsolete for empty tags:
Code:
<span x="y"/>
	<div id="w"/>
As ebooks are "zipped", it saves nothing. Compact (as with clever C that should take 3 lines fitted as one statement) is not always a good idea.
Quote:
The HTML WG has discussed this issue: the intention was to allow old (HTML-only) browsers to accept XHTML 1.0 documents by following the guidelines,
So, yes, every browser will accept <div />, <span /> etc if the doc type allows it, but it's actually now wrong and totally inappropriate for ebooks.
mobi is HTML3
azw3 & epub2 is HTML5
epub3 is extended.


Here is a list of self closing tags for web pages. The ones used in ebooks listed above and in bold. <col /> should be avoided in ebooks.
Code:
Name	Description
< !DOCTYPE html>	Special Case, never use a forward slash. Used to tell the browser what type of document you are using.
 <br />	Used to create a breaking space on a page. Content following this tag will be moved to the next line in the browser.
<area />	Used for image mapping, making specified areas of an image clickable by associating a hyperlink
<base />	Creates a base url for all other hyperlinks on a given webpage so that relative urls can be used. The base element is placed inside the head.
<col />	This element represents a column or several columns in a column group
 <command />	 A multipurpose element for representing commands.
 <hr />	 Horizontal rule – creates a horizontal line across the page.
 <embed />	 Used to embed multimedia objects such as a video into a page.
 <input />	 This element allows a visitor to enter information such as username, password, email address etc…
 <link />	 Used to link external pages to a webpage such as external style sheets.
 <wbr />	 Word Break Opportunity. Specifies where in a line of text it would be OK to break into the next line on different screen sizes.
 <track />	 Used in conjunction with audio or video to add subtitle or caption tracks.
 <meta />	 A multipurpose element used to represent metadata. Metadata is information about data.
 <param />	 Defines parameters for object elements such as audio or video
 <source />	 Allows multiple media sources to be specified for audio and video elements.
 <keygen />	 Control used to generate a key pair (public – private) and allows the public key to be submitted to the user.
 <img />	 Image – Used to add images  to a web page.
This isn't definitive.

However while <span /> <div /> etc can be legal in all browsers in web pages, I've never seen such in ebooks in 12 years and never used them in 30 years of web site editing.
Quoth is offline   Reply With Quote