to or not to - Post ID 75769

User 597929 Photo


Registered User
1,332 posts

I've long ago learned to use <br> for addiing a line break. Recently in some literature I've begun to see people using <br />, instead. I can see where it would be more "correct" since most (if not all) other single-line tags also use the /> as a terminator. Is this becoming the standard, or is it just coincidence I've only recently begun to see it used that way?
"You can't be a real country unless you have a beer and an airline - it helps if you have some kind of a football team, or some nuclear weapons, but at the very least you need a beer." -- Frank Zappa

Visit Spinland Studios: http://www.spinland.biz
User 37670 Photo


Registered User
2,138 posts

The <br> tag is HTML, and the <br /> tag is XHTML. Note the space after br, then the />? so, <br/> is incorrect, and <br /> is correct. If you are building your web page to XHTML specs, then you must close all tags, including <img <br <hr and others.
E-Learning Specialist
www.mainsites.ca is my website, and yes, some of it is crappy.
User 37670 Photo


Registered User
2,138 posts

btw, most browsers will display your code properly, even if you get them mixed up.

The doctype is what decides how you are going to code your page. Without a doctype, the browser guesses at what you want.

XHTML doctype example:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


HTML doctype example:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
E-Learning Specialist
www.mainsites.ca is my website, and yes, some of it is crappy.
User 597929 Photo


Registered User
1,332 posts

Got it; figured it was something like that. Thanks!

I presume VSD doesn't produce XHTML (yet).
"You can't be a real country unless you have a beer and an airline - it helps if you have some kind of a football team, or some nuclear weapons, but at the very least you need a beer." -- Frank Zappa

Visit Spinland Studios: http://www.spinland.biz
User 463058 Photo


Ambassador
1,086 posts

I've only seen VSD pages made with the html doctype. Even if it has xhtml, there isn't anything to be gained by using it.
User 37670 Photo


Registered User
2,138 posts

HTML is slowly migrating in 2 directions. There is XHTML as a standard, and HTML5 is being developed as a standard. Both will be similar to HTML, but each will have specific characteristics that differ from normal standard HTML code.
Websites that are coded properly to these new standars will get higher placement in search engines and will display consistently in different browsers, as the browser will not use the "quirks mode" to display your web page. If errors are found in the coding, "quirks mode" becomes enabled and tries to guess at what you wanted, making different browsers display the same page differently, based on their best 'guess'.

As with any changes, the HTML 5 will take time to be adopted. XHTML is already a set standard.

Like always, most browsers will be backwards compatible, so pages written in valid HTML4 should display normally, even after the standards are changed.
E-Learning Specialist
www.mainsites.ca is my website, and yes, some of it is crappy.
User 96903 Photo


Registered User
70 posts

My experience is that writing HTML pages deliberately to "quirks mode" with the design based on the now said to be old fashion table structure, that is no DOCTYPE prologue and <body><center><table...> </table></center></body> (and a CSS to take care of all internal margins, paddings, fonts and colors) is the safest way to make pages look the same in all browsers.

Having said this I must admit I am trying to create new pages in the more "modern" way - all CSS based with the prologue and no tables. I have tried both HTML4 and the XHTML and found no difference between them. Therefore I stick to HTML4 so that I don't have to bother with these ending slashes on specific tags. My pages are simple stright forward HTML and some JavaScripts, may be there is a difference for more complicated sites (Any advice on this will be appreciated).

With CSS based design pages are almost guaranteed to display differently in Internet Explorer and Firefox. I have recently learned some tricks to work around some what I will call bugs in FF (or bugs in the W3 standard) formatting. In most cases I find that IE7 is interpreting my code according to my intentions right away as FF does not. Most experienced and more advanced codewriters disagree with me I know. They say that it is IE that interprets wrongly and has to be worked around. But it seems to me that IE "thinks" closer to the way I - with less experience - do.
www.nkmoller.com
- You may help me once by doing something for me, you help me a multiple of times by teaching me how to do it myself.
User 463058 Photo


Ambassador
1,086 posts

NK Moller wrote:
I have tried both HTML4 and the XHTML and found no difference between them. Therefore I stick to HTML4 so that I don't have to bother with these ending slashes on specific tags. My pages are simple stright forward HTML and some JavaScripts, may be there is a difference for more complicated sites (Any advice on this will be appreciated).


No, there shouldn't be a difference as xhtml 1.0 isn't something new and advanced. It is simply a reformulated html 4.01. However, serving xhtml as just html, which everyone does, is really no better than writing mangled html to begin with.
User 37670 Photo


Registered User
2,138 posts

We are lucky that browsers can interpret the code, and usually pretty darn close to what we intended. Ford and Toyota both make cars, those cars both get us to the grocery store, they have similar parts, do similar functions but we get to choose which one we drive based on what we like that's "different". I think browser preference can work along the same principle. Asking all browsers to be exactly the same takes away preference and choice...imo

We can choose our coding preference, and thankfully if we make a mistake the browser will do a good job of covering our butts. I think it's a great system.

I personally agree that I.E. is a good product that has the best "show me what I built" capability, and it does it for free! Sweet deal.
E-Learning Specialist
www.mainsites.ca is my website, and yes, some of it is crappy.
User 364143 Photo


Guest
5,410 posts

Actually, I think when IE displays my pages differently, it is my coding that is the problem (and sometimes ie bugs) and not FF.
CoffeeCup... Yeah, they are the best!

Have something to add? We’d love to hear it!
You must have an account to participate. Please Sign In Here, then join the conversation.