validator.w3.org - Post ID 73933

User 55304 Photo


Registered User
72 posts

I can’t understand why the validator.w3.org is giving me errors for the <Br /> HTML Code

My site code is something like
"<br /><br />text in here "

But the validator suggests I write
"<br ><br >text in here "


Can any way see any logic in this??

Thanks


User 355448 Photo


Ambassador
3,144 posts

JaneA,

It depends on the doctype you are using. XHTML requires <br/> while HTML uses <br>

One of the issues is that HTML may be expecting a closing tag for a previously used open tag, and close that tag early.

As an example, if you use HTML doctypes, and close your meta tags, the validator will think that you have closed your <head> tag.

On your site http://www.freelance-consultant.co.uk/ you do not have a doctype, so the validator will make some assumptions.

By not having a doctype, you will also make the browsers enter quirks mode, and they may not display your page as you want the page displayed.
User 55304 Photo


Registered User
72 posts

Hi BillR,

Thank you for your prompt reply, Sorry I should have explained fully as it was my site I was refering too.

I am using Coffee Cup to create a new site.
www.ludlow-click.com however coffecup set the doctype and I saved it as HTML. Should I have saved it as XHTML?

If you could take a look I would appreciate it,

Thanks
User 55304 Photo


Registered User
72 posts

typo error..................as it was NOT my site I was refering too.
sorry for typo :)
User 355448 Photo


Ambassador
3,144 posts

JaneA,

The choice of using XHTML or HTML is up to you. I have made a couple of pages using XHTML, and find it difficult to use all the things I want to use and still validate the code. Validation is not a requirement, but it does point to errors in the code that if left may not work properly as browsers upgrade and become more standards compliant.

Using the CoffeeCup HTML editor, you can fix line 7 by removing the / at the end of that meta tag, and then take care of all the <br /> tags with the find and replace.

Just press CRTL-H and in the top box enter <br /> and in the second box enter <br> then click on replace all. Upload the changed file and see how the validator works.
User 55304 Photo


Registered User
72 posts

So Bill, If I stay with HTML, which I prefer, and I remove all the / from the BR command, will all browsers read the site ok?

I'm aiming for 100 pass from validator.w3.org .................. It's just a mission I am on :)

The site is in the very early stage so now is the time for perfection.
User 355448 Photo


Ambassador
3,144 posts

JaneA,

I wouldn't go so far as to say all browsers, but the major ones tend to do better with validated code. There may be problems with IE on some occasions, but you can generally fix that with an IE only bit of code.
User 55304 Photo


Registered User
72 posts

Yes Bill, IE8 is what is bothering me to be honest,

I read an article that they are going to be displaying sites to the validator.w3.org standred and therefore older site will have to put in a fix to display websites under IE7 rules if they are not validated.

If this article is true then it is Kinda worrying if you create sites for businesses’ like myself
User 55304 Photo


Registered User
72 posts

Bill, I have done what you suggested. .............thanks for that...... I am down to two errors and one warning, but when I remove a < from in front of the <table> tag like the validator suggests, I then get loads more errors, it doesn't make sense.


Any suggestions.

the url is www.ludlow-click.com

thanks
User 355448 Photo


Ambassador
3,144 posts

JaneA,

Here is a look at the problem code:
<body>

<body bgcolor="" text="#000000" link="#99401c" vlink="#CB5634" alink="#FF0000" background=""

<table width="1000" border="0" cellpadding="0" cellspacing="0" bgcolor="#ffffff">

Delete the first line <body> since you are putting your styles in the next body tag. You could remove the styles and put them in a style section of your page, or in a separate style page, but what you have will work.

There is nothing wrong with the <table entry, but the validator gets hung up because of the previous entry which needs to have background="" removed since it is un-needed, and you need to have a > added to that line. Thus those three entries should become two entries, and should look like:

<body bgcolor="" text="#000000" link="#99401c" vlink="#CB5634" alink="#FF0000">

<table width="1000" border="0" cellpadding="0" cellspacing="0" bgcolor="#ffffff">

That should fix your validation problem.

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.