InterviewSolution
| 1. |
How to use comments in HTML and when to use them? |
|
Answer» Comments in any programming language is used by developers to keep track of what the next BLOCK of code will do or means. It is very useful when the project grows big and many developers work on it. A well commented code can be easily understood by all other developers working on the project, then the one who wrote it. Comments are ignored by the compiler which runs the code, and in case of HTML it’s the browser. HTML comments are a bit different than other languages. In JavaScript we can comment a line by using //. WHEREAS in HTML to comment a line(s) we place it between <!— and —>. We will add comments to our demo.html file from Question 4. <!DOCTYPE html> <html> <HEAD> <title>The Attribute Demo</title> </head> <style> .page__heading{ font-size: 1.5rem; color:blueviolet; } .alt__para{ font-size: 1.2rem; color:chocolate; } </style> <!--Body starts here--> <body> <h1 id="page__heading">Heading</h1> <p class="alt__para">Lorem ipsum dolor, sit amet consectetur adipisicing ELIT. Doloribus, quis?</p> <!--Below is an example of inline styling, which can be used directly in HTML tags--> <p style="font-family:arial; color:#FF0000;">Lorem ipsum dolor sit amet.</p> <p class="alt__para">Lorem ipsum dolor sit amet consectetur adipisicing elit. Quidem, quibusdam!</p> </body> <!--Body ends here--> </html> |
|