Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there an HTML element that is ignored during rendering?

Tags:

html

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?

Some context

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.

like image 863
Paul Tarjan Avatar asked Sep 08 '10 21:09

Paul Tarjan


1 Answers

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.

like image 53
rfunduk Avatar answered Oct 21 '22 04:10

rfunduk