Reputation:
I've got a component on which I need to show an image:
import React from 'react'
import background from '../media/content-background.jpg'
function ContentPage(){
return(
<div id="content-page">
<div id="content-header">
<img href={background} alt='back'/>
</div>
<div id="content-body">
</div>
</div>
)
}
export default ContentPage
The image is generated correctly as when I go to the url as specified in the inspector, it shows up in the browser.
But on the webpage only the alt is shown:
Upvotes: 1
Views: 79
Reputation: 65
Change href to src. href is used for anchor tags and src is used for img tags
Upvotes: 1
Reputation: 4489
The problem is that you are using the wrong attribute in your img
tag, use src
instead:
<img src={background} alt='back'/>
Upvotes: 1
Reputation: 400
You should use src=""
instead of href=""
.
href is used for specifying where you want a link to go, such as in an tag.
Upvotes: 2