Ask Your Question

How to import style from html file?

asked 2019-07-21 16:03:04 +0200

billjordanchess gravatar image

updated 2019-07-21 16:06:49 +0200

In LibreOffice Writer I select the menu

Insert>Text from File

I choose an html file and it mostly works fine.

I want to import some styles with the document. In the html file its with the p> tag, e,g. p class=mystyle>abc

It works except that it messes up the formatting by adding a paragraph break. (its inside a table so it's a disaster.)

I have tried importing the same style with span, div, pre, b none work.

Is there a tag pair I can use that Writer will recognize?

edit retag flag offensive close merge delete

2 Answers

Sort by » oldest newest most voted

answered 2019-07-21 18:39:16 +0200

ajlittoz gravatar image

You must understand Writer is not an HTML composer, i.e. you won't write manually HTML tags, elements or attributes.

When formatting, Writer understands its own styles. Formatting is controlled by paragraph, character, list and frame styles (page styles are not relevant for HTML). You can also experiment with direct formatting, i.e. applying formatting variants with toolbar buttons, but this ersatz for styles is not recommended.

When you save the document with filename extension .html, the internal structure is translated by an export filter, converting the styles (and anonymous formatting) to CSS. You can't inject directly CSS or interfere with HTML tag attributes.

In Writer, whenever you hit Return, this creates a paragraph (not a line break), eventually empty (this explains why you should never use the Return key for vertical spacing). Then, paragraphs are always translated as <p class=some_style>Contents of paragraph</p>. Empty paragraphs come as <p class=some_style></p> resulting in blank space (at least padding+border size).

To answer your question, use Writer "as usual" to layout your document, without caring for CSS styles or switch to an HTML dedicated composer.

To show the community your question has been answered, click the ✓ next to the correct answer, and "upvote" by clicking on the ^ arrow of any helpful answers. These are the mechanisms for communicating the quality of the Q&A on this site. Thanks!

edit flag offensive delete link more

answered 2019-07-22 16:29:15 +0200

billjordanchess gravatar image

I have decided to use images instead of tables which resolves the above problem. I have written a short program which converts the tables to jpgs. This also removes the problem of tables splitting over pages.

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower


Asked: 2019-07-21 16:03:04 +0200

Seen: 48 times

Last updated: Jul 22