We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Background color move to child element

I want to set the background color on the outermost"div". After i save the document, i notice that this style was remove from outside “div” , and move to child element. For example, “div style=‘background-color:#808000;’><div” will be replace with "div><p style=“background-color:#808000;>”

Here is the sample code:
SampleCode.zip (602 Bytes)

@velaskec

Thanks for your inquiry. Please note that Aspose.Words mimics the behavior of MS Word. If you open the HTML in MS Word and convert it to HTML, you will get the same output. Please check the screenshot.

However, we have logged this problem in our issue tracking system as WORDSNET-17801. You will be notified via this forum thread once there is an update available on this issue.

Do you have any workaround to avoid this issue?

@velaskec

Thanks for your inquiry. The shared issue is not a bug. So, we have closed it as “Won’t Fix” resolution.

The <div> blocks like the one used by you cannot be represented in the model and are ignored on load. As a workaround, you could use a table cell instead of <div>. That is, replace

<div style=‘background-color:#808000;’>…</div>

with

<table><td style=‘background-color:#808000;’>…</td></table>