HTML Diff
0 added 0 removed
Original 2026-01-01
Modified 2026-03-09
1 <p>Our card does not have a picture of the product. Let’s create it with makeElement, transferring the 'img' tag name and 'product__image' class to the function. We are not going to transfer the third parameter, because the image has no text content.</p>
1 <p>Our card does not have a picture of the product. Let’s create it with makeElement, transferring the 'img' tag name and 'product__image' class to the function. We are not going to transfer the third parameter, because the image has no text content.</p>
2 <p>To make the picture appear on the page, we need to specify the image file address, that is, the value of the src attribute. The value of this<em>attribute</em>can be managed using the<em>property</em>of the DOM element with the same name:</p>
2 <p>To make the picture appear on the page, we need to specify the image file address, that is, the value of the src attribute. The value of this<em>attribute</em>can be managed using the<em>property</em>of the DOM element with the same name:</p>
3 var picture = document.createElement('img'); picture.src = 'images/picture.jpg'<p>In the same way, we will add an alternative text to the image, that is, a description of the photo. If the photo does not load, the page will display this text so that the user understands what kind of block they are looking at. In addition, this text is recognized by the electronic reader; that is why, when adding this description, we just make the interface element available in a user-friendly way. Add alternative text using the alt property. As you can see, the names of <em>tag attributes</em>and<em>properties of DOM elements</em>are often (but not always) the same.</p>
3 var picture = document.createElement('img'); picture.src = 'images/picture.jpg'<p>In the same way, we will add an alternative text to the image, that is, a description of the photo. If the photo does not load, the page will display this text so that the user understands what kind of block they are looking at. In addition, this text is recognized by the electronic reader; that is why, when adding this description, we just make the interface element available in a user-friendly way. Add alternative text using the alt property. As you can see, the names of <em>tag attributes</em>and<em>properties of DOM elements</em>are often (but not always) the same.</p>
4 picture.alt = 'Unsinkable selfie stick';<p>After creating the image and setting its properties, add the image to the card. Please note, we must add the photo before the product price, because the order of the tags is exactly like this in the layout. Therefore, the code for creating a picture needs to be added before the price creation code.</p>
4 picture.alt = 'Unsinkable selfie stick';<p>After creating the image and setting its properties, add the image to the card. Please note, we must add the photo before the product price, because the order of the tags is exactly like this in the layout. Therefore, the code for creating a picture needs to be added before the price creation code.</p>