0

I'm new to HTML coding, and I seem to be having problems with the <img> tag. My code, which I type in VS Code, is linked up to a Github repo, which is linked to Netlify which I use as the host for the site.

I'm trying to get an image into the <main> section of the code, but I just always get the alternative text for the image.

<img src="tratt_1080x1080.jpg" alt="lot182" class=".floatRight">

That's the code for the image.

.floatRight {
float: right;
width: 300px;
max-width:50%;
margin-left: 10px;
margin-bottom: 10px;
}

That's the CSS code for the class floatRight.

the result on the actual site

2
  • And does the image exist at that URL? In the browser's debugging tools, what is the network request made for the image? What is the server's response?
    – David
    Commented Apr 18, 2022 at 20:09
  • 2
    You don't need to include the class selector . in the markup. Should be class="floatRight"
    – Kameron
    Commented Apr 18, 2022 at 20:12

3 Answers 3

1

Your image and files should be in the same folder. Also you don't need to use "." in your tag. Remove "."

0

In css we use a . to indicate that the following name is a class. So in html we don't need that name, because we already specify that it's a class. (remove the dot in the class atribute).

<img src="tratt_1080x1080.jpg" alt="lot182" class="floatRight">
0

There can multiple reasons of it why it is happening, but make sure you have you have spelled your image file correct in the img tag tally it with care even be careful about the extension of the image its '.jpg' or 'jpeg'. Second make sure your image is place at the correct place location. According to your img tag it must be placed in the same folder as your html file is placed Third correct your class attribute don't place a dot with it here, you should place it to access this class in CSS file with a dot not where you are defining it in the html tag

Not the answer you're looking for? Browse other questions tagged or ask your own question.