By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,257 Members | 928 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,257 IT Pros & Developers. It's quick & easy.

Different renderings of <br/> and <br></br> in IE6

P: n/a
Something that I recently noticed in IE6 (I don't know whether it is true
for other browsers or versions of IE) is that it renders <br/and <br></br>
differently. With the <br/version, which is what most people use when they
write static code (some people use <br>, but with xhtml you are required to
close all tags), IE6 simply breaks to the next line like it is supposed to.
However, with <br></br>, which is what is sometimes generated by certain
server-side code (for example, ASP.NET/VB.NET's HtmlGenericControl("br")
class renders <br></br>), an extra blank line is rendered. IE6 appears to be
interpreting <br></bras <br/><br/>, but <br/and <br></brare supposed
to be the same thing (<br/is just the self closing syntax of <br></br>),
so there shouldn't be a difference in how the browser renders them. Does
anybody have any comments on this? Thanks.
--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/
Aug 3 '07 #1
Share this Question
Share on Google+
7 Replies


P: n/a
br is not an encapsulation element, like img.

<br /- transitional, usually your best practice, mind the space in
there, this should work in most older browsers.
<br/- strict, wont work in some older browsers. unless your entire
site must validate as strict use transitional.

I've never seen <br></branywhere, I don't believe it exists in any
spec.

Aug 3 '07 #2

P: n/a
Hi Nathan,

In addition to Tomi's reply, please note HtmlGenericControl is not invented
for <brtag but span/body/div/font. Alternatively, use
LiteralControl("<br>") / LiteralControl("<br />") or WriteBreak() method of
the HtmlTextWriter class.

HTH
--
Milosz
"Nathan Sokalski" wrote:
Something that I recently noticed in IE6 (I don't know whether it is true
for other browsers or versions of IE) is that it renders <br/and <br></br>
differently. With the <br/version, which is what most people use when they
write static code (some people use <br>, but with xhtml you are required to
close all tags), IE6 simply breaks to the next line like it is supposed to.
However, with <br></br>, which is what is sometimes generated by certain
server-side code (for example, ASP.NET/VB.NET's HtmlGenericControl("br")
class renders <br></br>), an extra blank line is rendered. IE6 appears to be
interpreting <br></bras <br/><br/>, but <br/and <br></brare supposed
to be the same thing (<br/is just the self closing syntax of <br></br>),
so there shouldn't be a difference in how the browser renders them. Does
anybody have any comments on this? Thanks.
--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/
Aug 3 '07 #3

P: n/a
Thank you for that suggestion, but I would like to point out that I am not
designing a CustomControl, I am simply dynamically adding a line break to a
page. In my specific case, using the LiteralControl is good enough (which is
what I decided to do), but because that does not allow me access to
properties such as Clear that the br tag has, it can make it harder, or at
least more complicated, to write code in certain cases (it can be a pain to
generate the html by hand, even if it is simple). All they really need to do
is add a property to HtmlGenericControl like IsSelfClosingTag that specifies
whether or not the tag is self-closing. Is that really that much to ask?
Thanks.
--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/

"Milosz Skalecki [MCAD]" <mi*****@DONTLIKESPAMwp.plwrote in message
news:06**********************************@microsof t.com...
Hi Nathan,

In addition to Tomi's reply, please note HtmlGenericControl is not
invented
for <brtag but span/body/div/font. Alternatively, use
LiteralControl("<br>") / LiteralControl("<br />") or WriteBreak() method
of
the HtmlTextWriter class.

HTH
--
Milosz
"Nathan Sokalski" wrote:
>Something that I recently noticed in IE6 (I don't know whether it is true
for other browsers or versions of IE) is that it renders <br/and
<br></br>
differently. With the <br/version, which is what most people use when
they
write static code (some people use <br>, but with xhtml you are required
to
close all tags), IE6 simply breaks to the next line like it is supposed
to.
However, with <br></br>, which is what is sometimes generated by certain
server-side code (for example, ASP.NET/VB.NET's HtmlGenericControl("br")
class renders <br></br>), an extra blank line is rendered. IE6 appears to
be
interpreting <br></bras <br/><br/>, but <br/and <br></brare
supposed
to be the same thing (<br/is just the self closing syntax of
<br></br>),
so there shouldn't be a difference in how the browser renders them. Does
anybody have any comments on this? Thanks.
--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/

Aug 5 '07 #4

P: n/a
On 5 , 06:05, "Nathan Sokalski" <njsokal...@hotmail.comwrote:
All they really need to do
is add a property to HtmlGenericControl like IsSelfClosingTag that specifies
whether or not the tag is self-closing. Is that really that much to ask?
Thanks.
Hi, Nathan
I guess it is not developer's affair to decide whether BR has or has
not additional slash. In HTML there are 2 types of tags: single(br,
hr, img ...) and paired (div, span ...). Whether a single tag will be
closed - solution depends on doctype declaration used in your pages.
If doctype is HTML4.0 (default in Visual Studio 2003) then br is
rendered <br>.
If doctype is XHTML (default in Visual Studio 2005) then br is
rendered <br/>.
Look here, maybe it will be helpful.
http://www.w3schools.com/xhtml/xhtml_html.asp

Regards, Mykola
http://marss.co.ua

Aug 6 '07 #5

P: n/a
On 8 , 04:23, "Nathan Sokalski" <njsokal...@hotmail.comwrote:
I do not believe that is completely correct. As I mentioned in my original
posting, I have used methods in VB.NET that generate <br></brand I could
not find a class that was a control, in other words, one that I could set
properties for that would determine the attributes of the generated tag.
Rendering HtmlGenericControl("BR") in the form of "<br></br>" is no
more than bug
and you should not exploit this and try to customize.

My workaround was to use the Literal control, but this required me to set
the Mode and Text properties, which means longer code, which would not be
necessary if there was a class for the <br/tag.
Use LiteralControl from System.Web.UI namespace.
LiteralControl br = new LiteralControl("<br/>");
Regards, Mykola
http://marss.co.ua
Aug 8 '07 #6

P: n/a
Your code example of using the Literal control is great, except for one
thing: It does not set the Mode property to PassThrough, which is necessary
to avoid having the text converted to something that uses html character
codes such as &lt; and &gt;. Because the Mode property cannot be set in the
constructor, it requires an extra line of code. I think the message I am
trying to get across in this thread is that it should not require this much
extra code to simply add a server control that will usually have no
attributes and have nothing changed during runtime except the visible
property.
--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/

"marss" <ma******@gmail.comwrote in message
news:11**********************@q75g2000hsh.googlegr oups.com...
On 8 , 04:23, "Nathan Sokalski" <njsokal...@hotmail.comwrote:
>I do not believe that is completely correct. As I mentioned in my
original
posting, I have used methods in VB.NET that generate <br></brand I
could
not find a class that was a control, in other words, one that I could set
properties for that would determine the attributes of the generated tag.

Rendering HtmlGenericControl("BR") in the form of "<br></br>" is no
more than bug
and you should not exploit this and try to customize.

>My workaround was to use the Literal control, but this required me to set
the Mode and Text properties, which means longer code, which would not be
necessary if there was a class for the <br/tag.

Use LiteralControl from System.Web.UI namespace.
LiteralControl br = new LiteralControl("<br/>");
Regards, Mykola
http://marss.co.ua


Aug 12 '07 #7

P: n/a
On 12 , 04:21, "Nathan Sokalski" <njsokal...@hotmail.comwrote:
Your code example of using the Literal control is great, except for one
thing: It does not set the Mode property to PassThrough, which is necessary
to avoid having the text converted to something that uses html character
codes such as < and >. Because the Mode property cannot be set in the
constructor, it requires an extra line of code. I think the message I am
trying to get across in this thread is that it should not require this much
extra code to simply add a server control that will usually have no
attributes and have nothing changed during runtime except the visible
property.
--
Nathan Sokalski
njsokal...@hotmail.comhttp://www.nathansokalski.com/

"marss" <marss...@gmail.comwrote in message

news:11**********************@q75g2000hsh.googlegr oups.com...
On 8 , 04:23, "Nathan Sokalski" <njsokal...@hotmail.comwrote:
I do not believe that is completely correct. As I mentioned in my
original
posting, I have used methods in VB.NET that generate <br></brand I
could
not find a class that was a control, in other words, one that I could set
properties for that would determine the attributes of the generated tag.
Rendering HtmlGenericControl("BR") in the form of "<br></br>" is no
more than bug
and you should not exploit this and try to customize.
My workaround was to use the Literal control, but this required me to set
the Mode and Text properties, which means longer code, which would not be
necessary if there was a class for the <br/tag.
Use LiteralControl from System.Web.UI namespace.
LiteralControl br = new LiteralControl("<br/>");
Regards, Mykola
http://marss.co.ua
We are talking about two different conrols.
Not Literal control from System.Web.UI.WebControls namespace but
LiteralControl control from System.Web.UI namespace.

Regards, Mykola
http://marss.co.ua

Aug 13 '07 #8

This discussion thread is closed

Replies have been disabled for this discussion.