![]() ![]() Use a single-line comment when you want to explain and clarify the purpose behind the code that follows it or when you want to add reminders to yourself like so: As mentioned earlier, that line will not get displayed in the browser. How to Write Single-Line Comments in HTMLĪ single-line comment only spans one line. Your comments can clearly explain to them why you added certain lines of code. ![]() It also reminds you what you were thinking/doing when you come back to a project after months of not working on it.Ĭomments also help you communicate with other developers who are working on the project with you. Comments help you document and communicate about your code and thought process to yourself (and others). Writing comments is helpful and it's a good practice to follow when writing source code. So your comments will be visible for others to see if you make the HTML document public and they choose to look at the source code. That being said, keep in mind that anyone can view the source code of practically every website published on the Internet by going to View -> Developer -> View Source – and this also includes all comments! This means that any comments you add to your HTML source code will not be shown when the document gets rendered in a web browser. HTML comments don't get displayed in the browser. The tag surrounds any text or other HTML tag you want to comment out. The general syntax for an HTML comment looks like this: ĭon't forget the exclamation mark at the start of the tag! But you don't need to add it at the end. You'll also see why comments are considered a good practice when writing HTML code. In this article, you'll learn how to add single and multi-line comments to your HTML documents. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |