When should you use embed vs img for gif or jpeg?

In the exercises, you can use <embed> to embed gif or jpeg images to the page. How is this different from <img>?

For example, isn’t this doing the same thing?

<embed src="http://url.com/blargle.gif" title="a big meal">

vs

<img src="http://url.com/blargle.gif" alt="a big meal">

Hello @teawithducks!! Welcome to the Codecademy community!! :grinning:

I have not used the <embed> element much, but from what I understand it is an older element that as at first used for pictures videos and more, instead of the newer elements such as <img>.

In fact MDN documentation lists it as depreciated, and no longer recommended for use:

According to the text embed has been replaced with the other more specific elements, and is not supported by several modern browsers.

But in short, yes they do the same thing, one is just newer than the other.

Thanks!

Should we then default to <img> as much as possible for images and avoid using <embed>? Is <embed> being taught in the semantics html section as a matter of legacy code?

Based on the documentation, I would say to avoid the <embed> tag since it is not always supported.

As for this, I am not really sure. It could be that when the lesson was written it was still being used, and the lesson needs to be updated.