I'm looking for a way to add comments to HTML 5, meaning text that is not executed but is there to help understand the programming. In CSS I see /* comment */ used for that purpose. In HTML, I see comments, but it's not clear how they are flagged as comments.
For example, I've seen <!-- comment-->, but that syntax also seems to be used for conditional statements that are executed, as in <!--[if gt IE 8]><!-->. That looks like it's written as a comment, but obviously it's meant to be executed. I think. I just want to be able to safely add comments to the HTML code, but I need help with the syntax. THanks!
So far you have everything right.
<!--this is an HTML comment-->
/**this is a CSS Comment**/
Conditional comments for IE are ignored by ALL browsers except IE9, 8, 7, 6.
IE10 no longer pays attention to conditional comments.
Interesting-- so, old IE reads comments to see if they contain conditional statements, and executes them if they do, but otherwise ignores them if they are just comments? Put another way, how does old IE know that a comment contains a conditional statement unless it "reads" the comment?
I guess the reason I'm struggling a bit with this is that in other types of programming I've done, such as Visual Basic, a comment is ignored by the software executing it-- even if the comment contains executable code (in fact, you can troubleshoot code by "commenting out" a line).
But your response was very helpful, Nancy. Thanks!
Comments are ignored. Scripts inside comments won't execute.
IE Conditional Comments are hacks. They always begin with an IF statement which only IE browsers see.
<!--[if lt IE 9]>
Why did MS do this? To mitigate the fact that IE browsers are not standards compliant. Instead of fixing the problem like they should have done a decade ago, MS decided to make a window so developers could workaround the serious shortcomings in these inferior browsers. Nice, huh?
IE10 promises to be standards compliant thus won't need any hacks. Cross your fingers.