where should I put it, if I want to add an image, css or html?

Recommended Answers

The easiest way to add an image is via HTML, using the <img/>element. However, you can assign a background image to certain elements.

I don't think there is a right or wrong.. What are you trying to accomplish?

Jump to Post

Generally, if its part of the page or menu structure then put it in the CSS, using the background-image property.

If its part of the content, then in the markup. That way you can make sure the Alt tag is filled out properly and an individual that's using an AT …

Jump to Post

All 6 Replies

The easiest way to add an image is via HTML, using the <img/>element. However, you can assign a background image to certain elements.

I don't think there is a right or wrong.. What are you trying to accomplish?

i want to do the best practice to add an image

to put an image(the best practice to do is), use "HTML" and use the "<img />" tag with "src" attribute.

There is no "best practice" to code images into a web page, there's only a correct syntax of doing it!
Which is the image tag: <img src="...">

A correct code/syntax is always the best practice.

Generally, if its part of the page or menu structure then put it in the CSS, using the background-image property.

If its part of the content, then in the markup. That way you can make sure the Alt tag is filled out properly and an individual that's using an AT (Assistive Technology) device can understand what the image is about.

commented: I agree! +0

A correct code/syntax is always the best practice.

i don't think so

Generally, if its part of the page or menu structure then put it in the CSS, using the background-image property.

If its part of the content, then in the markup. That way you can make sure the Alt tag is filled out properly and an individual that's using an AT (Assistive Technology) device can understand what the image is about.

thanks, i think this helps

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.