I have this markup
<html>
... some HTML ...
And I need to wrap it with an element like this:
<html>
<div class="user-content">
... some HTML ...
</div>
The problem, is ... some HTML ...
can be lots of different things from raw text to complicated markup.
<div>
If I use a <div>
, then it adds a block-level break. Meaning if I had
Paul is cool
now I have
<div class="user-content">
Paul is cool
</div>
which forces a line break.
<span>
If I use a <span>
then weird things start happening when I have a <span>
contain a <div>
. For example, the width of the span is shown as 0px which makes javascript not too happy with that node.
Is there a better tag I can use?
It's a long story. I need the node to exist in the HTML since I'm running untrusted javascript and I don't want the javascript to be able to walk inside that node. To do that, we've sandboxed all the DOM functions, and at each DOM call, we'll check if we're operating on a "user-content" node and not allow access if we are walking there or to any of its children.
If your only problem with using a div is the line break when why not just give it the style: display: inline;
?
If you can be more specific about your problem... Why do you have to wrap it?
Basically, div
is what you want, just style it appropriately.
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