1

How can i insert a html comment between two double quotations:

<img src="<!--comment-->Image.jpg"/>

this is not working.

rdonuk
  • 3,921
  • 21
  • 39
  • 4
    I'd hate to be the one to ask, but why would you want to do this? Also, see [Multiple inline comments for html](http://stackoverflow.com/questions/13144860/multiple-inline-comments-for-html) – Boaz Mar 04 '13 at 14:59
  • this html creating in a server side java code. And i must add this like that because related java method turn to me only the attribute's value. So i cant add a comment outside of the quotations. – rdonuk Mar 04 '13 at 15:02
  • @TimMedora It's not actually a duplicate. The author of this question is asking how to comment inside an attribute value. The linked question is asking how to comment an attribute entirely. – RB. Mar 04 '13 at 15:07
  • @RB - Boaz's link would be a better duplicate, but I think both linked questions answer sufficiently..."comments are markup; you can't do it.". – Tim M. Mar 04 '13 at 15:13
  • So I just want to note that while you can't use html comments in the manner that the OP wants, can you not add comments specific to the language of the attribute? E.g. You can add css comments inside a style attribute : style = "/*display:block*/" or javascript comments inside an onclick attribute. – TorranceScott Mar 31 '14 at 16:01

1 Answers1

2

The W3C documentation suggests it cannot be done:

This basically means that a <!-- ...> comment tag is just like any other tag, so <a <!--title="need to be comment out"-->>a link</a> is as wrong as <a <span></span>>a link</a>.

source: How to comment HTML tag attribute in HTML source code?

Community
  • 1
  • 1
Eric Goncalves
  • 5,253
  • 4
  • 35
  • 59
  • Why post a duplicate as an answer? – Boaz Mar 04 '13 at 15:03
  • @Boaz It's not actually a duplicate. The author of this question is asking how to comment *inside* an attribute value. The linked question is asking how to comment an attribute entirely. – RB. Mar 04 '13 at 15:07
  • @RB Granted. But the question itself is already flagged as a duplicate. See my comment to OP. – Boaz Mar 04 '13 at 15:10
  • @RB - Boaz posted a better [duplicate link](http://stackoverflow.com/questions/13144860/multiple-inline-comments-for-html) before anyone answered. I should have used that one for the "close as duplicate" vote. Sorry for the confusion. – Tim M. Mar 04 '13 at 15:14