سؤال

I'm creating a webpage that produces formatted text, which is then copy&pasted into Microsoft Word 2010. Everything works fine, except I have to support hanging indent. The method I found to produce hanging indent using CSS with margin-left: 1cm; text-indent: -1cm;. This works fine on the page, but doesn't work when copied over to word, as the margin-left part is lost.

Thus, the beginning lines of all paragraphs are shifted left, instead of all others being shifted right.

Example (put into a HTML file, then copy from Firefox to Word):

<div style="margin-left: 1cm; text-indent: -1cm;">
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Vestibulum eu nunc ut nunc dictum molestie.
Ut et porttitor leo, at tincidunt neque. 
Integer vulputate sed odio nec aliquam.</div>

Edit: Fixed typo

هل كانت مفيدة؟

المحلول

Self-answer, as I figured it out after I'd already written the question.

The key is to use a p tag instead of a div. Then it works, for whatever reason. If you want to test it yourself, check out the demo I've written up.

<p style="margin-left: 1cm; text-indent: -1cm;">
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Vestibulum eu nunc ut nunc dictum molestie.
Ut et porttitor leo, at tincidunt neque. 
Integer vulputate sed odio nec aliquam.</p>
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top