Adding a comment is a very important tool to understand when using HTML, PHP, etc.
Comments allow coders to:
- Stay organized
- Easily pinpoint code to edit/fix
- Create reference points without appearing on webpages
For example, if you were writing an HTML page and wanted to organize the different sections, you could make an HTML comment to create reference points within the HTML.
<!DOCTYPE html> <html> <head> <title>Foods R' Us</title> </head> <body> <h1>My Favorite Foods</h1> <!--This is a comment about your first food--> <h3>Eggs</h3> <p>Eggs are the most white and beautiful things on the planet.</p> <!--This is a comment about your second food--> <h3>Ham</h3> <p>Ham is also the best! It is meaty and good.</p> <!--This is a comment about your first food--> <h3>Watermelon</h3> <p>Watermelon makes me want to go skydiving.</p> </body> </html>
Click here to see the webpage we just created! (Notice that the comments do not show up.)
Code Weapon: Textedit (Mac) or Notepad (PC)