views:

69

answers:

2

I wrote this bit of code because I wanted images to appear in the same place regardless of how many bullet points the user fills out in the CMS. IF they don't fill in a spot for a bulleted link or text, it just puts a break rule. What I don't get is why IE requires a   before the break rule for the break rule to take effect. It worked fine Chrome, FF, and Opera without it. What I'm referring to is in the statement.

<cfif len(promos.link1text) gt 0 AND len(promos.link1url) gt 0>
<li><a href="#promos.link1url#">#promos.link1text#</a></li>
<cfelseif len(promos.link1url) gt 0>
<li><a href="#promos.link1url#">#promos.link1url#</a></li>
<cfelseif len(promos.link1text) gt 0>
<li>#promos.link1text#</li>
<cfelse>&nbsp;<br/> </cfif>

+1  A: 

That code will generate invalid HTML - a <ul> or <ol> cannot directly contain a <br /> tag. This is probably why you're getting inconsistent results.

And Randy is right - there should be a space in the <br /> - although I wouldn't have thought that was what was causing the problem.

Mark B
What happens if you neglect the space in <br />? I haven't been putting that space in there ever, and this is the first time I've had issues, and apparently they aren't even related.
reggie
The correct markup is <br /> for XHTML. Depending on which DOCTYPE you choose and browser you view the markup with will determine how forgiving that browser will render syntax.
randy melder
I think the space is a matter of preference. In the XHTML specs: http://www.w3.org/TR/xhtml1/#h-4.6 I don't see anything that says a space is required and the samples don't show a space. I prefer not to add the space as I find it much easier to read and I have yet to find any browser issues.
scunliffe
To make it clear: **there does *not* need to be a space in `<br/>` tags**.
Peter Boughton
+1  A: 

In addition, you will want to run your code through validation to see what syntax improvements you can make:

http://validator.w3.org/check/referer

randy melder