Lucas
Lucas

Reputation: 359

<img src> tag doesn't work properly (MVC, HTML)

Here is my code (part of the Index.cshtml file):

<div class="col-md-6">
        <h2>Warunki wypozyczenia</h2>
        <p>
            Kazdego wypozyczajacego obowiazuja jednakowe zasady dotyczace wypozyczonych ksiazek. <br />Najwazniejsze z nich:
            <ol>
                <li>Nie jedz z ksiazka.</li>
                <li>Myj rece przed czytaniem.</li>
                <li>Nie kap sie z ksiazka.</li>
                <li>Jesli jestes strazakiem, zostaw ksiazke w bazie przed akcja ratunkowa.</li>
            </ol>
        </p>
        <img src="~\Content\DataTables\images\rules.png" alt="Rules" />
    </div>

This is project structer:

enter image description here

In the code, when I mouseover it, image shows up:

enter image description here

On the site there is error:

enter image description here

I have tried refactoring path to this file but nothing helped.

Any ideas?

Upvotes: 0

Views: 64

Answers (2)

Israel
Israel

Reputation: 37

Change this line of code

<img src="~\Content\DataTables\images\rules.png" alt="Rules" />

to

<img src="~\Content\DataTables\images\rules.jpg" alt="Rules" />

You need to consider the extension in you image. "png", "jpg"

hope that helps

Upvotes: 3

Nitin S
Nitin S

Reputation: 7601

are you using \ instead of /?

correct way is

<img src="~/Content/DataTables/images/rules.png" alt="Rules" />

Upvotes: 2

Related Questions