...

View Full Version : XHTML comments



CaptainB
07-07-2007, 12:01 PM
Hi!

When I try to comment more lines out like below:


<!--................................
...RIGHT SIDE BOXES END......
...................................-->

I get an error in the W3C validator. How do I then comment more lines out?

Jutlander
07-07-2007, 12:11 PM
Try this: It should work.



<!--

RIGHT SIDE BOXES END

-->

Jutlander
07-07-2007, 12:36 PM
I believe the reason yours isn't working is because there must be a space after the starting tag and before the closing tag.

CaptainB
07-07-2007, 02:13 PM
@Jutlander: Det er fordi, at jeg gerne vil have nogle tegn imellem lukke- og åbne tagsene, så det bliver mere overskueligt. (Sorry, I couldn't in English..)

And I have tried with space between the closing and opening tag, no difference.

_Aerospace_Eng_
07-07-2007, 03:56 PM
Got link?

Arbitrator
07-07-2007, 03:59 PM
It would be helpful if we could see the entirety of the code and/or the actual error message.

One issue that I can think of is when you place a comment as the sole content of an element that must have a child element (e.g., the body element under a Strict DTD).

Another is if you have an XML (XHTML) document and the comment contains the character sequence “--”. Placing two Hyphen‐Minus (-) characters adjacent to one another within comment tags is illegal in XML.


<!------ illegal XML comment ------>
<!-- illegal -- XML and SGML (HTML) comment -->

If using HTML, there needs to be an even number of comment delimiters (--) and the comment text needs to occur after every odd delimiter.

CaptainB
07-07-2007, 04:10 PM
Hi guys.

It works if I just have one line like this, but that's just a single line:


<!-- COMMENT -->

@ Arbitrator: Yes, you are right. It's illegal to put more than the 2 opening and closing "--"s in the comment.

Here ya are, the link (just view source): http://www.xflightx.port10.com/test/main-layout.php

I KNOW that I have used "--"s which is illegal, but it dosn't work with "...."s and "###"s either.

Arbitrator
07-07-2007, 04:36 PM
I KNOW that I have used "--"s which is illegal, but it dosn't work with "...."s and "###"s either.You’re going to have to fix this problem for all of the comments. I suspect that the errors will go away once you do that.

To make things clearer, know that the boundary of a comment is, technically, not defined by <!-- and -->. It’s defined by -- and --.


<!---- comment --><div></div><!------>

In the above code, everything in green is commented out and everything in red is in an illegal position. Thus, it’s possible that errors in one comment may cause errors in subsequent comments since two comments may not be as separate as they appear.

You might want to also remove the comment above the document type declaration since that puts Internet Explorer in quirks mode. Firefox seems to be in quirks mode as well. Oddly, you have a lot of markup commented out, but Firefox is showing it anyway; I suspect that quirks mode is the reason for that. Internet Explorer has never handled SGML comments correctly, so I wouldn’t expect any issues there.

CaptainB
07-07-2007, 04:54 PM
Ok, I have now replaced all the illegal "--"s in the comments, and removed the comment in top of the page. However it didn't change anything here (IE6).

Oh, and thanks for the explanation of the comment "lines".

Arbitrator
07-07-2007, 05:08 PM
Ok, I have now replaced all the illegal "--"s in the comments, and removed the comment in top of the page.You have one validation error remaining: you forgot the end tag for an h2 element.

I made a slight mistake before. You don’t have a missing h2 tag. You have a form element inside of an h2 element. That’s illegal in HTML/XHTML.

However it didn't change anything here (IE6).The rendering of Internet Explorer 6 looks fine from here.

Firefox is out of quirks mode and looks better than it did before. However, the right column wraps to below the content column and my Firefox Adblock extension is blocking the image named banner.gif.

CaptainB
07-07-2007, 05:47 PM
Lol...It also looks fine for me now - dono what happened.
However I have now decided, how strange it may sound, to stick with the original comments...Anyways, Do u guys also see the "3" number near the bottom of the site?

Oh, and does the blocker still block the banner?

Arbitrator
07-07-2007, 06:23 PM
.Anyways, Do u guys also see the "3" number near the bottom of the site?If you mean, “Total votes: 3”, then, yes, I see it.


Oh, and does the blocker still block the banner?I see the banner now. Personally, I wouldn’t use the word banner at all though, since there may be stricter ad‐blockers out there. The terms “logo”, “head”, “header”, “heading”, “masthead”, “branding”, etc. are all possible alternatives.

CaptainB
07-07-2007, 06:30 PM
No, not that. See this screenshot:

http://www.xflightx.port10.com/pro.jpg


And thanks for the tips with the banner text - I see what you mean.

And just one more question: How would I get the footer to align completely with the bottom line? I have tried to apply following to the div, but without any effect:

vertical-align:bottom
and
margin-bottom:0px;

_Aerospace_Eng_
07-07-2007, 06:47 PM
That duplicate character is caused by...wait for it...the use of to many html comments in between floats.

http://www.positioniseverything.net/explorer/dup-characters.html

Also I notice you are using IE6. You do realize that this is the root of all of your problems? Code for a good browser like Firefox and tweak for IE. I can't test on IE6 unless I install a virtual machine on Vista which I haven't done yet.

CaptainB
07-07-2007, 07:47 PM
Thanks for the link, interesting!

However if I use the -3 margin trick it works, but my layout gets messed up. I also tried with the "<!--[if !IE]>Put your commentary in here...<![endif]-->", however I can't figure out if I should use it for all the comments or not? I tried to use it with the last 2 (sandwich) comments, but that didn't work out..?

_Aerospace_Eng_
07-07-2007, 08:00 PM
Thanks for the link, interesting!

However if I use the -3 margin trick my layout gets messed up. I also tried with the "<!--[if !IE]>Put your commentary in here...<![endif]-->", however I can't figure out if I should use it for all the comments or not? I tried to use it with the last 2 (sandwich) comments, but that didn't work out..?
Then you likely didn't use the trick properly. We've been trying to tell you that you have a lingering </h2> towards the bottom of your code. I think that closing </h2> should go up here

<h2>Hi and welcome to <b>XflightX!</b>
<br />
Remove the <br /> and replace it with that closing </h2>

CaptainB
07-07-2007, 08:22 PM
Why do you think that I'm missing that tag? If you look a little further down you will see this (the whole code):


<h2>Hi and welcome to <b>XflightX!</b>
<br />
The site has now got an "extreme makeover", so feel free to browse around and see what's new!
Enjoy your stay and please feel free to <br /><a href="contact.php">contact me</a><br /> if you have any queries.</h2>

The only error I get if I validate the document is this (http://validator.w3.org/check?uri=http%3A%2F%2Fwww.xflightx.port10.com%2Ftest%2Fmain-layout.php). And that error isn't a part of the main-layout.php document, but part of another file, which has this code where the error is:


if ($votingstep==1) {
write2log("Enters Poll");
setcookie("votingstep","2",time()+$time_between_votes);
$mainstr=$message1;
$step1str='<form action="'.$callingfile.'" method="post" name="form1">';
$totalvotes=SumArray($itemvoted);
$in=0;
$datop=count($item);
while($in<$datop){
$step1str=$step1str.'<input type="radio" name="radios" value="'.$in.'"/> '.stripslashes($item[$in]).'<br/>';
$in++;
}
$step1str=$step1str.'<br/><input style="'.$buttonstyle.'" type="submit" value="'.$vote_str.'"/></form>';
}

So as I said, I still don't get what to do (if I should use the "<!--[if !IE]>Put your commentary in here...<![endif]-->" tag for ALL my comments) or what else would be the solution? Sorry, but english isn't my native language, I'm only 15 and that's why I might have some troubles getting it all right. I appologize.

Arbitrator
07-07-2007, 08:40 PM
Why do you think that I'm missing that tag? If you look a little further down you will see this (the whole code):


<h2>Hi and welcome to <b>XflightX!</b>
<br />
The site has now got an "extreme makeover", so feel free to browse around and see what's new!
Enjoy your stay and please feel free to <br /><a href="contact.php">contact me</a><br /> if you have any queries.</h2>Reread my previous post, which I edited awhile ago. You’re not missing a tag as I had originally mentioned. You’ve nested a block‐level element (a form element) inside of an h2 element; this is illegal HTML/XHTML. Obviously, a form cannot be a header.


The only error I get if I validate the document is this (http://validator.w3.org/check?uri=http%3A%2F%2Fwww.xflightx.port10.com%2Ftest%2Fmain-layout.php). And that error isn't a part of the main-layout.php document, but part of another file, which has this code where the error is:


if ($votingstep==1) {
write2log("Enters Poll");
setcookie("votingstep","2",time()+$time_between_votes);
$mainstr=$message1;
$step1str='<form action="'.$callingfile.'" method="post" name="form1">';
$totalvotes=SumArray($itemvoted);
$in=0;
$datop=count($item);
while($in<$datop){
$step1str=$step1str.'<input type="radio" name="radios" value="'.$in.'"/> '.stripslashes($item[$in]).'<br/>';
$in++;
}
$step1str=$step1str.'<br/><input style="'.$buttonstyle.'" type="submit" value="'.$vote_str.'"/></form>';
}This is incorrect. The W3C validator only validates the current file and, obviously, can’t check your PHP code since that stuff is on the server‐side.

If you check the “Show Source” box and click the “Revalidate” button, you can compare the line and column numbers of the error (in this case, line 283 and column 57) against the source code (which has line numbers to the left) for your document to find out exactly where the error is.


So as I said, I still don't get what to do (if I should use the "<!--[if !IE]>Put your commentary in here...<![endif]-->" tag for ALL my comments) or what else would be the solution?The article referenced suggested that you replace all instances of <!-- with <!--[if !IE]> and --> with <![endif]-->. Your comments would go in between.


<!--[if !IE]> My comment goes here. <![endif]-->

CaptainB
07-07-2007, 08:49 PM
Reread my previous post, which I edited awhile ago. You’re not missing a tag as I had originally mentioned. You’ve nested a block‐level element (a form element) inside of an h2 element; this is illegal HTML/XHTML. Obviously, a form cannot be a header.

So I can't use a <b> tag inside the h2 tags? If it's that, wouldn't it then be legal to do it liks this: <b><h2>text</h2></b>?


This is incorrect. The W3C validator only validates the current file and, obviously, can’t check your PHP code since that stuff is on the server‐side.

If you check the “Show Source” box and click the “Revalidate” button, you can compare the line and column numbers of the error (in this case, line 283 and column 57) against the source code (which has line numbers to the left) for your document to find out exactly where the error is.

As I only have a total of 111 lines in my document I believe it's correct what I'm saying. This is obviously the text which is linking, or whatever it
s called, to the document:


<?php echo($question); ?>
<br />
<?php if($votingstep==1) { echo($step1str); }
if($votingstep==2) { echo($step2str); }
if($votingstep==3) { echo($step3str); }?>
Total votes: <?php echo($totalvotes); ?>


The article referenced suggested that you replace all instances of <!-- with <!--[if !IE]> and --> with <![endif]-->. Your comments would go in between.
Thanks - that was what I wanted to be confirmed.

Arbitrator
07-07-2007, 09:17 PM
So I can't use a <b> tag inside the h2 tags? If it's that, wouldn't it then be legal to do it liks this: <b><h2>text</h2></b>?I never said that. The bit of code there is invalid since block‐level elements may not be placed within inline elements. h2 is bold by default anyway so your code is redundant. If that’s not enough for you, you can use the correct method to make the text bold: CSS.


h2 { font-weight: bold; /* or */ font-weight: bolder; }


As I only have a total of 111 lines in my document I believe it's correct what I'm saying. This is obviously the text which is linking, or whatever it
s called, to the document:You might want to actually try what I mentioned:


If you check the “Show Source” box and click the “Revalidate” button, you can compare the line and column numbers of the error (in this case, line 283 and column 57) against the source code (which has line numbers to the left) for your document to find out exactly where the error is.

CaptainB
07-07-2007, 09:38 PM
I never said that.
I know that and I didn't say that u said that. I just googled the therm "block‐level elements" and found out that <b> was one of them. And I know how to make the text bold using CSS, but since I only needed this little word to be bold I wouldn't use the CSS since I also use the <h2> for other bits of text.



If you check the “Show Source” box and click the “Revalidate” button, you can compare the line and column numbers of the error (in this case, line 283 and column 57) against the source code (which has line numbers to the left) for your document to find out exactly where the error is.

The error is following:


Error Line 283, column 57: document type does not allow element "form" here; missing one of "object", "applet", "map", "iframe", "ins", "del" start-tag .

...ayout.php" method="post" name="form1"><div><input type="radio" name="radios"

And this is my code for that line:


<form action="main-layout.php" method="post" name="form1"><div><input type="radio" name="radios" value="0"/> Yes, it's great!<br/><input type="radio" name="radios" value="1"/> The old was better..<br/><input type="radio" name="radios" value="2"/> I don't care about the design.<br/><br/><input style="" type="submit" value="Vote"/></div></form>Total votes: 3</h2></div>

I don't see what's wrong with that? Is it the name "form1" that it refers to as "form" element? Cause I can't really see what's wrong..

BWiz
07-07-2007, 09:50 PM
You've probably put the <form> element (thanks Arbitrator for correcting me) inside a tag which it is not allowed to be in. I've done the same mistake many times.

Arbitrator
07-07-2007, 10:03 PM
I know that and I didn't say that u said that. I just googled the therm "block‐level elements" and found out that <b> was one of them.b is an inline element.

Block‐level elements have display: block set. Think of it as any element that automatically starts a new line when used and that automatically expands to fill the available width. Examples are div and p. Tables (display: table;) are an odd exception. They are also considered to be block‐level and don’t automatically expand.

Inline‐level (or just “inline”) elements have display: inline set. They go inline with text. span, br, and cite are examples. Think of these elements as those that do not invoke new lines and that cannot have widths and heights set. Odd exceptions include img, object, and form control elements. Unlike normal inline elements, you can set widths and heights on them.


And I know how to make the text bold using CSS, but since I only needed this little word to be bold I wouldn't use the CSS since I also use the <h2> for other bits of text.I would keep all of your stylistic stuff in one place: a style sheet. In the long run, things are easier to maintain. Use classes or IDs if necessary.


I don't see what's wrong with that? Is it the name "form1" that it refers to as "form" element? Cause I can't really see what's wrong..<form>content</form> is the element. form is the element name. <form> is the form element start tag. </form> is the form element end tag. content is the form element content.

Let’s take your code:


<div id="paddingdiv1"><h2>Do you like the new web?<br />
<form action="main-layout.php" method="post" name="form1"><div><input type="radio" name="radios" value="0"/> Yes, it's great!<br/><input type="radio" name="radios" value="1"/> The old was better..<br/><input type="radio" name="radios" value="2"/> I don't care about the design.<br/><br/><input style="" type="submit" value="Vote"/></div></form>Total votes: 3</h2></div>

Let’s make it easier to read:


<div id="paddingdiv1">
<h2>Do you like the new web?<br />
<form action="main-layout.php" method="post" name="form1">
<div>
<input type="radio" name="radios" value="0"/> Yes, it's great!<br/>
<input type="radio" name="radios" value="1"/> The old was better..<br/>
<input type="radio" name="radios" value="2"/> I don't care about the design.<br/>
<br/>
<input style="" type="submit" value="Vote"/>
</div>
</form>
Total votes: 3
</h2>
</div>

What does h2 represent? It represents a second‐level header. Is a form a second level header? No. The form element is clearly inside of the h2 element.

h2 also does not allow block‐level elements inside of it. form is a block‐level element. The form element is clearly inside of the h2 element.

Let’s fix the code now:


<div id="paddingdiv1">
<h2>Do you like the new web?</h2>
<form action="main-layout.php" method="post" name="form1">
<div>
<input type="radio" name="radios" value="0"/> Yes, it's great!<br/>
<input type="radio" name="radios" value="1"/> The old was better..<br/>
<input type="radio" name="radios" value="2"/> I don't care about the design.<br/>
<br/>
<input style="" type="submit" value="Vote"/>
</div>
</form>
Total votes: 3
</div>

Problem solved.

CaptainB
07-07-2007, 10:25 PM
Problem solved.

Wow...It actually is! Everybody who replied in this thread, thank you so much! But most of the thanks go to Arbitrator :thumbsup:

You actually learned me a lot about the elements and what's allowed and what's not. I'll remember it and I'll for sure bookmark this thread!

Again thanks!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum