When copying text from <dd> styled to select all text in Firefox, leading whitespace is appended

Viewed 59

I noticed something strange about how Firefox treats data copied from <dd> elements styled to have their content all selected with a single click. Note that the styling used here comes directly from the MDN user-select example. I have only observed this behavior on <dd> elements.

On Firefox, using Windows 10, if you were to click the first <dd> element used in the following HTML, then copy its contents you will notice when pasting the copied result into notepad that leading whitespace is prepended to the text content. This does not happen in Chrome or Edge. However, dragging and selecting data from the second <dd> does not result in the prepended whitespace when copying.

I am unsure of the behavior seen when using other OS's.

<dl>
 <dt>Title</dt>
 <dd style="-moz-user-select: all;
  -webkit-user-select: all;
  -ms-user-select: all;
  user-select: all;">Click me and get leading whitespace in FF, not chrome or edge</dd>
 <dt>Another Title</dt>
 <dd>Drag and select on me and get no leading whitespace</dd>
</dl>

My question: is there additional styling needed to get this to behave as expected (not leading whitespace) in Firefox? I know there are programmatic alternatives but I think that really shouldn't be necessary for this case.

0 Answers
Related