homepage Welcome to WebmasterWorld Guest from 54.205.106.111
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / HTML
Forum Library, Charter, Moderators: incrediBILL

HTML Forum

    
Help needed with code validation
Escape Artist




msg:4207555
 3:54 pm on Sep 27, 2010 (gmt 0)

Hey I am getting frustrated at the validator, it keeps bring up some stupid errors. I will post them some are similar: ( the things in brackets are the problem tags)

I used the <br/> tag and i got this message:
document type does not allow element "br" here; missing one of "ins", "del", "h1", "h2", "h3", "h4", "h5", "h6", "p", "div", "pre", "address", "fieldset" start-tag


then i got this message:

element "u" undefined

<h2 style="color:Orange"><u(>)Menu</u></h2>

These two:
character ";" not allowed in attribute specification list
character data is not allowed here
<table border="1" (;) (a)lign="left">

there is no attribute "width"
there is no attribute "color"
element "font" undefined
alt="Fish and Fries"/></td><td width=(")150px"><font color=(")#00FF00"(>) Fish and

if you guys could help me out that would be great

[edited by: tedster at 6:38 pm (utc) on Sep 27, 2010]
[edit reason] I disabled the graphic smile faces [/edit]

 

kaled




msg:4207687
 8:37 pm on Sep 27, 2010 (gmt 0)

document type does not allow element "br" here

Webmasters don't normally offer psychic readings on Mondays so perhaps you could offer a clue as to precisely what doctype you are using - my guess would be xhtml-strict meaning that switching to html-transitional might help (or might make things worse).

The semicolon problem can be eliminated by deleting the semicolons - attributes are separated by white-space only.

Kaled.

Escape Artist




msg:4207824
 1:43 am on Sep 28, 2010 (gmt 0)

I am using:
<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">

milosevic




msg:4208005
 10:09 am on Sep 28, 2010 (gmt 0)

I used the <br/> tag and i got this message:
document type does not allow element "br" here; missing one of "ins", "del", "h1", "h2", "h3", "h4", "h5", "h6", "p", "div", "pre", "address", "fieldset" start-tag


This is pretty clear - a br tag is used for adding line breaks for text (or that's what it should be used for) - all those elements are ones that would normally be a text container. If you are misusing it for presentation to get blocks to drop onto a new line (or even worse, to add whitespace/padding between elements), you are doing it wrong - the answer is to use CSS styles - display:block or float: instead, depending on situation, or margin-bottom: to add margins/whitespace below something.

If you are competent with CSS you generally shouldn't need a single <br> tag on your entire site. <br> tags break up semantic presentation and greatly increase the chance of unusual inputs or design tweaks breaking your site and causing headaches.

Exactly the same is true for <br>'s retarded cousin, <p>&nbsp;</p>

kaled




msg:4208324
 6:40 pm on Sep 28, 2010 (gmt 0)

<br> is a soft linebreak.

Why do people get so caught up in what is and what isn't semantically right? If anyone can come up with a sound, logical argument as to why <br> is evil I would be mightily impressed and here's why...

Typically, text will be contained in paragraphs <p>. CSS will be used to determine what spacing is used between each paragraph. However, if you simply want to start a new line but with the standard spacing (not the paragraph spacing) then <br> does the job - that's precisely what it's designed for.

As for other uses such as inserting some non-critical padding, so what? The only other way to do this for an individual paragraph is with a style statement and I defy anyone to argue logically that doing it this way is somehow more semantically correct - that's clearly wrong since it means hiding the intended break from non-css viewers!

Kaled.

milosevic




msg:4208614
 9:16 am on Sep 29, 2010 (gmt 0)

I said, if you are misusing it - obviously using it as a soft line break in text is the legitimate use. However I have found it good practice to avoid this in anything except pure text content.

There are problems such as linebreaks depending on the line-height property that's set, the lack of fine control and that 2 or 3 well written CSS rules can usually take the place of literally hundreds of presentational <br>s round a site, reducing the size of pages.

If it was a single paragraph on the site I might use a br to add padding at the bottom, but I wouldn't feel good about it and would add a new class of paragraph if there were 2 or more instances. I don't agree about how hiding this break from non-css viewers is wrong though - a break like this must be purely cosmetic in purpose, therefore it shouldn't be shown to viewers who have styles disabled. This idea goes against the principle of separation of content and presentational mark-up.

futureX




msg:4208632
 10:36 am on Sep 29, 2010 (gmt 0)

The validator seems to indicate the BR is in the wrong place, the other errors are more clear cut your ";" should not be there at all, no idea why you have it there.

the <u> tag is not part of XHTML standard, you should use CSS to underline instead.

Same goes for TD, width should be supplied by css, and your font statement should be replaced with a better css substitute.

tedster




msg:4208794
 4:00 pm on Sep 29, 2010 (gmt 0)

The validator seems to indicate the BR is in the wrong place

Yes - I'd look for an earlier tag or quote that is accidentally still open - for example, maybe an unclosed attribute.

Escape Artist




msg:4209051
 10:09 pm on Sep 29, 2010 (gmt 0)

In the original post I should given my experience and purpose. I am taking a introduction course to HTML and Web Development and my professor wants us to make a webpage for a restaurant, and he told us to use <br/> to make line breaks. I'm trying to keep it as simple as possible. He only introduced <p> <table> <img> <br/> and maybe 1 style and classes, he didnt go over them in much detail. And has anyone found out why some of my " marks seem to come up as errors?

or am I getting confused with C++ which is the other language course I am taking at the same time as my HTML course

rocknbil




msg:4209055
 10:24 pm on Sep 29, 2010 (gmt 0)

Your <br>'s probably aren't validating because you have generic text that is not surrounded by valid tags.

Change your doctype to HTML 4.01 transitional, or strict if you're feeling brave It will make for a less steep learning curve for you. XHTML has different guidelines and you're probably doing plain old HTML anyway.

The <u> indeed has been long deprecated, use

<span style="text-decoration:underline">this</span>

instead, although it should be rare - underlined text is generally confused with hyperlinks, not great for your users, which is probably why it was deprecated.

Escape Artist




msg:4209092
 11:08 pm on Sep 29, 2010 (gmt 0)

ok I removed the underlining and I also removed the BR's. Now each of my errors is either a " or a >

futureX




msg:4209224
 7:37 am on Sep 30, 2010 (gmt 0)

The errors with the "'s are not indicatin/g that the quotation marks themselves are a problem, it's saying that those attributes are not part of XHTML.

<td width="150px">

Should be

<td style="width:150px;">

and

<font color="#00FF00"> Fish and

should be something like

<span style="color:#00FF00;"> Fish and </span>

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / HTML
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved