Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

diff btw '<!-...->' and '<!--.. -->'

 
Jingh Yi
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys,

I know <!--... --> is the comments for jsp, xml, etc. but what about <!- .. ->? Is that the html comments?

Thanks!
Jenny
 
Matthew Taylor
Rancher
Posts: 110
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<!-- and --> are html comments, too.

<!- and -> won't work.
 
Jingh Yi
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried this code:



The page only shows one line of 'Have a nice day'.
 
Joe Sondow
Ranch Hand
Posts: 195
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jingh, you're correct that web browsers will not display anything for
<!-Have a nice day->

However, it's not because that's a comment. It's because that's an invalid tag. You'll get the same results for other invalid tags including any of the following:
<!Have a nice day->
<!-Have a nice day>
<!Have a nice day>
<Have a nice day>

Browsers are designed to be flexible with all sorts of errors in html code, so a browser won't tell you if you have any invalid code like that. It will simple try to work around it, in this case by not displaying anything for that tag. If you were to run your code through a validator, however, it would tell you that you have an invalid tag. Also, if you used such a tag in an XHTML or XML document that was being parsed by a program that expected the code to be error-free, you'd have a problem. And if you were using DOM to collect data nodes from an XML document, that tag would not be included as one of the comments because it isn't formatted correctly to be a comment.
 
Jingh Yi
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks, Joseph! I didn't know that.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic