Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • AlexR 39 posts 61 karma points
    Apr 21, 2010 @ 13:11
    AlexR
    0

    Self closed empty div breakes design

    In XSLT I insert empty div to clear float.

    <div style="clear: both"></div>

     

    It generates short self closed div:

    <div style="clear: both" />

     

    Such self closed div breakes disign in ALL browsers. Usual closed does not.

    How can I generate usual closed div?

    I tried use

    <xsl:value-of select="&lt;div style="clear: both"&gt; &lt;div&gt;" disable-output-escaping="yes" />

    but I can not save such XSLT.

  • Ismail Mayat 4511 posts 10090 karma points MVP 2x admin c-trib
    Apr 21, 2010 @ 13:12
  • AlexR 39 posts 61 karma points
    Apr 21, 2010 @ 13:18
    AlexR
    0

    I do this!

    I generates empty usual closed div by using variable.

        <xsl:variable name="xxx">
    &lt;div&gt; &lt;/div&gt;
    </xsl:variable>

    <xsl:value-of select="$xxx" disable-output-escaping="yes" />

     

  • Rasmus Berntsen 215 posts 253 karma points c-trib
    Apr 21, 2010 @ 13:21
    Rasmus Berntsen
    0

    I usually just use a non-breaking space, like this:

    <div class="clear">&nbsp;</div>

    CCS:

    div.class{clear:both; height:0px;}

     

  • Peter Duncanson 430 posts 1360 karma points c-trib
    Apr 21, 2010 @ 16:54
    Peter Duncanson
    0

    I'd have thought the best solution is to use the technology as design and set the method of the output to be HTML. There are a few tags like this, switching this means you let the technology handle it all for you :)

    <xsl:output method="html" omit-xml-declaration="yes" />

  • Laurence Gillian 600 posts 1219 karma points
    Apr 21, 2010 @ 18:11
    Laurence Gillian
    0

    Its generally considered best practice to use...

    <div class="clear">&nbsp;</div>

    Regardless of location (XSLT macro, static page or template). Some browsers if you are using HTML Strict will take <div></div> and convert it to <div /> so its always worth using the nbsp method.

  • Lee 1130 posts 3088 karma points
    Apr 21, 2010 @ 18:22
    Lee
    0

    If you are just using the empty div to stop floated elements overflowing out of the surrounding div, then you can use CSS to achieve this and get rid of the div al together using the overflow:hidden; or overflow:auto; styles on the holding div.

Please Sign in or register to post replies

Write your reply to:

Draft