Commenting out is making an HTML code inactive. When you comment out some lines of code on your page, those lines will be still there and you will be able to see them in the WordPress HTML editor but they will not appear in the browser. There may be several situations when you wight want to comment lines of HTML code in WordPress.
- You want to put some additional information about a part of the HTML for future reference
- You want to put a comment before a part of the HTML code so that you can search the comment and go to that part directly if you need to
- You are testing some elements on the WordPress page or post and you don’t want to delete the code in case you need to revert back to it
In these situations commenting out option can come really handy.
The normal HTML comment out code is like this –
<!-- This is a comment in HTML -->
But sometimes it doesn’t work in WordPress. If that’s is the case try the following commenting out method:-
<!-- This is a comment in HTML <!-- -->
This will work in most of the situations.
Patrick Houlihan says
The normal HTML comment code is working for me to comment out text. However, if the comment includes any HTML tags, it won’t work. I tried both of the solutions on this page. Any ideas on what I can try? Thanks!