When there is an empty div
with contenteditable="true"
:
CSS:
[contenteditable="true"] {
border: 1px dashed #dedede;
padding: 3px;
}
HTML:
<div contenteditable="true">
<!-- blank by default -->
</div>
In IE and Chrome, it shows the height like a normal input field with small padding. In Firefox, it only shows that 3px padding I added in the styles. W/o that, it collapses and is only as tall as the border.
Do you know if this is a Firefox bug? Can you suggest a way to handle it?
Its totally secure. The contenteditable attribute is an enumerated attribute whose keywords are the empty string, true, and false.
The contenteditable attribute specifies whether the content of an element is editable or not.
The contenteditable global attribute is an enumerated attribute indicating if the element should be editable by the user. If so, the browser modifies its widget to allow editing.
Answer: Use the HTML5 contenteditable Attribute You can set the HTML5 contenteditable attribute with the value true (i.e. contentEditable="true" ) to make an element editable in HTML, such as <div> or <p> element.
workaround:
[contenteditable='true']:before {
content: "\feff ";
}
CSS2 section 10.6.3:
The element's height is the distance from its top content edge to the first applicable of the following:
- the bottom edge of the last line box, if the box establishes a inline formatting context with one or more lines
- the bottom edge of the bottom (possibly collapsed) margin of its last in-flow child, if the child's bottom margin does not collapse with the element's bottom margin
- the bottom border edge of the last in-flow child whose top margin doesn't collapse with the element's bottom margin
- zero, otherwise
For this empty div,
1 through 3 are not applicable, since the div is empty. It has no line boxes or children. Item 4 therefore applies.
The workaround enforces at least one line box inside the div, so that it gets nonzero height.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With