Umbraco is turning 5!
There's already 322 people signed up for the February 16th celebrations, what about you? join now

nested div tags

6/23/2009 6:04:19 PMAvatarStephane LandrevilleLocation: K2G 5x2posts: 1Karma:

Hello.

I'm currently running the latest release of Umbraco (4).

I used a lot of nested div tags in my code.
We are looking to use Umbraco to simplify our work.

But --- for some odd reason through my testing phase, when I try to use a nested div tag, it removes all internal tags and leaves me with only the external div tag.

Is there a way around this?

Here is an example of some code I was trying just to see:

  <div class="nifty-wrapper">
    <div class="nifty-title-box" style="width:460px; margin-bottom:10px; margin-top:10px;">
      <div class="nifty-title-left">
        <div class="nifty-title-right">
          <p class="nifty-title-content">2009 CPMA ANNUAL CONVENTION AND TRADE SHOW HIGHLIGHTS</p>
            </div>
        </div>
    </div>
</div>

Thanks in advance for your assistance.

Stephane

6/23/2009 8:03:54 PMAvatardillorscroftLocation: Crewe, UKposts: 103Karma: 37
Comment with ID: 7788

Stephane,

Can you post the XSLT/macro that generates these divs?

Umbraco by default will not change your divs within a template at all.  It's one of it's strengths.  If it's generated in an XSLT then there are some things to be aware off.  An empty div for instance will render as <div /> which most browsers will not tolerate.

DC

6/23/2009 8:06:26 PMAvatarquixltdLocation: bathgate, eh48 1hh, scotlandposts: 85Karma: 83
Comment with ID: 7789

Stephane,

You haven't said where you are entering your code. Is it in a template, or in an XSLT macro? 

If it's an XSLT macro, then I suspect this is a 'feature' of the xslt processing that also strips out the closing tag of an empty div tag and add the foward slash into the opening part of the tag:

    <div class="clear"></div>

becomes     <div class="clear" />

and this results in an error if you run your html through a validator and prevents styles being applied in some browsers

I use code like this to prevent it:

To prevent Umbraco stripping empty tag elements use CDATA like:

<xsl:text disable-output-escaping="yes"><![CDATA[

    <div class="clear"></div>

]]></xsl:text>

 

If this technique doesn't solve it, please say so, and someone else is sure to chip in.

Tom 

7/3/2009 12:14:19 AMAvatarGerbenLocation: Rotterdam posts: 30Karma: 68
Comment with ID: 8482

If you cannot use a CDATA section (for example of you still need xslt logic inside the div)  you can also insert and xsl:comment inside the div.

<div class="clear"><xsl:comment/></div>

This will create an html tag like this

<div class="clear"><!-- --></div>

Quite ugly actually, but it works.

7/10/2009 12:31:55 AMAvatarJesper HaugeLocation: Hillerød, Danmarkposts: 125Karma: 184
Comment with ID: 9211

Or you could try changing the output method:

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

to

<xsl:output method="html" />

This will make the xsl-parser leave your div tags empty, I think.

Regards
.Hauge

Please login or Sign up To post replies