If you are a web developer and working with HTML, then you may want to comment out some HTML block code or comment multiples line in HTML, so in this article, I have mentioned how you can simply comment multiples lines in HTML
In HTML, comment is text enclosed within < !? ?> tags, which tells browser not to render that text in front-end of website.
So for example, this is basic HTML comment.
<!--this is comment-->
Only a few browsers support the comment tag for commenting on a part of an HTML code.
HTML multiple lines Comments
HTML supports both single-line and multi-line comments. We can use multiple lines comments or block comments, by the beginning tag <!-- and ending tag -->.
<!--this is multiple line comment in HTML--> <div> Hello World</div>
<!-- this is a (multi-line) HTML comment --> <p>Some sample HTML</p> <div>Hello World</div>
You can check fiddle here:
However, do note that comment within a comment i.e. nested comment is not supported in the same way in HTML
<!-- <!-- Such Nested comments are unsupported --> Sample of ineligible multiline comment that can span across multiple lines within the html doc. -->
HTML Comment Shortcuts in Various IDE
- Visual Studio Code (VS Code) HTML Comment Shortcut: In Windows is 'Shift+Alt+A'.
- Visual Studio HTML comment shortcut: 'Ctrl+K+C'
- In Eclipse: For single line comment, you can use Ctrl + /, and for multiple line comments you can use Ctrl + Shift + / after selecting the lines you want to comment in the java editor.
- In Notepad++: CTRL + Q
- In Sublime: Ctrl + /, for multiple lines Ctrl+Shift+/
- In Dreamweaver: Ctrl + Alt + A
There are many more IDE, but I have mentioned some commonly used IDE HTML comment shortcut.
You may also like to read: