Content · Web Development · HTML

HTML Image Backgrounds: HTML Content vs CSS Decoration

A photograph inside an article may carry real information, while a background pattern often only decorates the page. Those are different jobs.

1 views Published Oct 19, 2026 Updated Oct 19, 2026 Admin

A photograph inside an article may carry real information, while a background pattern often only decorates the page. Those are different jobs. Think about what the picture adds to the story, not just whether it looks nice on the screen.

What You Need to Know


Use img for meaningful content and CSS backgrounds for presentation. Important information should not depend on a decorative background image being visible.

Pictures can make a page much easier to understand, but they are useful only when the file loads and the important meaning is also available as text.

Example: See It in Action


Try this markup in a fresh practice file. The next section explains the parts worth paying attention to.

This is a short HTML fragment. To try it as a webpage, put it inside the body element of a complete HTML document.

<article>
    <h2>Meet the sea turtle</h2>
    <img src="images/turtle.jpg" alt="Turtle swimming over coral">
    <p>The picture adds information to the story.</p>
</article>

Let’s Understand the Example


  • Img displays an image. Src chooses the file and alt provides a useful text alternative.
  • Article marks a piece that could make sense on its own, such as a news post or recipe.
  • Src tells the browser where to find an image or other embedded resource.
  • Alt supplies a text alternative for an image. Empty alt is appropriate for purely decorative images.

An image appears only if its file path is correct. If it is informative, its alt text should share the same useful meaning; if it is decoration, empty alt text is often right.

What Should You See?


If the image file is available, the picture appears in the page. If not, the browser may show a broken image or fallback text. The example alt text is “Turtle swimming over coral”. Check that the text alternative fits the picture’s purpose.

Cover the picture and read the surrounding text aloud. If essential information has disappeared, add a useful text alternative or nearby explanation.

Try It Yourself


  1. Decide whether a sample photo is part of the story or only decoration.
  2. Save your changes, open or refresh the page, and compare the result with the original example.
  3. Tell a friend what your change did. If you are not sure, undo it, refresh the page, and compare.

Common Beginner Mistakes


  • Putting the only version of a chart into a CSS background without a text explanation.
  • Never guess at an image description. Write alternative text that matches the picture and its purpose on this page.

Key Takeaways


  • A photograph inside an article may carry real information, while a background pattern often only decorates the page.
  • Img displays an image. Src chooses the file and alt provides a useful text alternative.
  • Use img for meaningful content and CSS backgrounds for presentation. Important information should not depend on a decorative background image being visible.
Share this resourceSend this page to someone who may find it useful.