| Commenting code and checking your StarfruitJuice files |
|
1-2 Explanation 1: HTML comments To add comments in HTML, enclose your comment within the characters shown below:<! Your comment here. > |
|
1-2 Explanation 2: Spaces in the comment tag There must be no spaces between the opening angle bracket, the exclamation mark and the first dash:<! Also, there must be no spaces between the last dash and the closing angle bracket: > |
|
1-2 Example 1: Uncommented and commented code
|
|
1-2 Explanation 3: Comments' visibility Comments in HTML files are not visible when the file is viewed in a browser. They can only be seen in the code. |
1-2 A 1
|
|
1-2 Example 2: Comments' visibility This code:<! About the carambola >will only show this line in a browser: The starfruit, also called carambola, is a sweet and sour fruit. |
|
1-2 Explanation 4: The purpose of comments Your code will certainly run without any comments, but there are several reasons why you should always comment your code. Comments
|
|
1-2 Explanation 5: Starting HTML files with a comment including the exercise number From now on, every exercise file you create should start with a comment that includes the exercise number: <!-- exercise number --> Make sure to follow the comment with a blank line. Although these comments are not included in the provided solutions, you must still begin the code for each exercise with the exercise number. |
|
1-2 Example 3: Starting HTML files with a comment including the exercise number For the next exercise, start with this line:<!-- 1-2A2 --> Note, that there is a blank space before and after the number in the comment. After the comment with the exercise number, include a blank line. Then write a comment for the first line of code, followed by the of code: <!-- 1-2A2 --> <!-- 1 times welcome --> Welcome. |
|
1-2 A 2
Create an HTML file that includes comments for this code: Welcome.<br> |
|
1-2 Explanation 6: Copying the file from a previous exercise For each exercise below, start with this step in the Exercises01 folder: create a copy of your HTML solution file from the matching exercise on the previous page. |
|
1-2 Orientation 2: Copying the file from a previous exercise In the next exercise, the cats exercise, you will be asked to first copy the previous cats file and then rename it to the name of that exercise. |
1-2 A 3 Cats
|
1-2 A 4 Dogs
|
1-2 A 5
Birds
|
|
1-2 A 6
What is missing in the following code? Animals live in many different places. <br>
|
1-2 A 7 Music
|
1-2 A 8 Games
|
1-2 A 9 Your own HTML files
|
|
1-2 A 10 Rereading the yellow sections
Now that you have gone through the exercises on this page, reread the yellow sections. |
|
1-2 Orientation 3: The StarfruitJuiceFiles folder Remember to save all of the StarfruitJuice files you will create in the following sections into the StarfruitJuiceFiles folder. |
|
1-2 Explanation 7: Creating a new StarfruitJuice file from a previous StarfruitJuice file While working with this workbook, you will create several StarfruitJuice files. To create a new StarfruitJuice file, make a copy of the latest StarfruitJuice file and rename the copy with the name of the new StarfruitJuice file. |
1-2 A 11
StarfruitJuice02.html
At this point you have 2 identical files, named StarfruitJuice01.html and
StarfruitJuice02.html.
|
|
1-2 Explanation 8: Checking your StarfruitJuice files Check each of your StarfruitJuice files after completing them by following the steps below.
|
|
1-2 Orientation 4: The importance of adding comments Adding comments to your code may seem unnecessary when the code is short and simple. And that is completely acceptable.But, as the number of code lines increases, uncommented code can easily become hard to understand later on. Therefore, start commenting from the beginning, even when the code is simple. This practice helps you to develop a very useful habit and will certainly assist you when reviewing your code at a later time. |
|
This page was created by Hanspeter Amend
|
|
|
Solution proposals 1-2 A 2 <!-- 1-2 A 2 --> <!-- 1 times welcome --> Welcome.<br> <!-- 2 times welcome --> Welcome. Welcome.<br> <!-- 3 times welcome --> Welcome. Welcome. Welcome.<br> <!-- 2 times welcome --> Welcome. Welcome. 1-2 A 5 <!-- 1-2A5 --> <!-- break --> Birds like to sing. They are good a building nests. <br> Some can fly long distances. Some birds like to fly in groups. <!-- paragraph --> <p>Not all birds can fly.</p> But all birds hatch from eggs. 1-2 A 6 <!-- 1-2A6 --> Animals live in many different places. <br> 1-2 A 11 <! Line break > The starfruit, also called carambola, is a sweet and sour fruit that is in the shape of a five-point star.<br> The skin is edible and the flesh has a mild, sour flavor that makes it popular in a number of dishes. <! Paragraph > |
|