Wrong page layout when exporting documents as .xhtml

Hi,

Whenever I export a document as .xhtml, the page ends up with screwed-up layout. Specifically, instead of subtracting the margins from the total page width, it basically exports a page without margins and then adds margins in addition to the total page width.

An 8-inch page with 1-inch margins is supposed to be a 6-inch writing area with two 1-inch margins (8 inches in total) - that’s how it’s displayed in LibreOffice Writer. But when I export the page as .xhtml, it becomes 8-inch writing area plus two 1-inch margins (10 inches in total instead of 8). The page becomes wider and screws up my formatting, especially the formatting of the images.

Is this a bug, or am I doing something wrong?

P.S. The reason why I’m using .xhtml is because it’s the only format that plays animated gifs. I don’t think I have any alternatives here.

You must be aware that HTML or XHTML formats are intended to be displayed and formatted by a web browser. In web browsers, there is no notion of page with wel defined dimensions. You have a display port that is mapped onto your screen through a window. A window has no fixed size (it is dynamic and can be adjusted by users as they like). Then the browser computes a layout to fit the current display port. If user resizes the window, the layout is updated.

In (X)HTML, you have no paper width. You can define margins, borders and padding which will be subtracted from the current display port and what is left is used to lay out your text.

If I misunderstood your work flow, please edit your question (don’t use an answer because this is not the solution to your problem) to describe precidely what you do (document created as HTML document or ordinary text document in web view), how you display the XHTML exported document (in which browser or other app).

OS and LO version

Thanks for your response.

I know that generally, web pages have no well-defined dimensions. However, the way LibreOffice exports the documents in XHTML is that it actually defines the fixed size of the the page. It will shrink on a smaller screen, yes, but won’t go beyond the original document size on larger screens.

However, that’s really annoying is that it goes into trouble of defining the fixed size of the exported page, but it does it wrong - specifically, it messes up the margins.

For example, if you created a libreoffice document without margins at all and exported is as XHTML, it will look exactly like the original document (in terms of page width, how many words fit per line, the size of images etc). But if you added margins, they will be subtracted from the total page width inside the doc, but added them instead to exported XHTML.

Hope this makes sense.

P.S. I tried different web browsers, it displays the same.