HTML Academy
JPEG format
Introduction to Backgrounds11/18
Back to the list of tasks
  • 1. The background-color Property
  • 2. The background-image Property
  • 3. The background-repeat Property
  • 4. The background-position Property
  • 5. A Little More on background-position
  • 6. The background-attachment Property
  • 7. The background Property
  • 8. Summary of “Backgrounds: An Introduction. Part 1”
  • 9. Challenge: Cat Comics
  • 10. JPEG format
  • 11. The PNG-8 Format
  • 12. PNG-24 format
  • 13. The GIF Format
  • 14. Multiple backgrounds
  • 15. Effects with a Repeating Background
  • 16. Sprites
  • 17. Summary of “Backgrounds: An Introduction. Part 2”
  • 18. Challenge: CAT Academy
PNG-24 format
  • Sign up
  • Log in

Loading…
Everything will be ready in few seconds

  • Theory
  • Theory
  • Comments

The PNG-8 Format

In fact, there is just one PNG format. PNG-8 and PNG-24 are its subtypes. There are also various save modes in Photoshop. We will not delve deep into details, but we will cover the standard features.

PNG-8 has characteristics that are similar to the GIF format. It works well for diagrams, drawings, graphs, and text, as well as for images where there are few colors. It supports a maximum of 256 colors.

PNG-8, like GIF, supports transparency. This means that the pixel is either completely transparent or completely opaque.

If you need to make an image with transparency, then it is better to set the outline to the same color as the background color. In Photoshop, when you save the outline, choose the “Matte” option. If you do not include an outline, your image with look nibbled away around the edges. If the background is not uniform (such as if it is a gradient, as in block 3 in the mini-browser), then a PNG-8 with an outline will look bad.

Why is PNG better than GIF? PNG is a more modern and open-source format, whereas GIF is older and more proprietary (it can be expensive to use). The compression level, quality, and other characteristics are about the same, so it’s best to always use PNG.

Comments

  • index.html
  • style.css
HTML
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>The PNG-8 Format</title> <link rel="stylesheet" href="style.css"> </head> <body> <div class="box box1"> <div class="block"></div> </div> <div class="box box2"> <div class="block"></div> </div> <div class="box box3"> <div class="block"></div> </div> </body> </html>
CSS
.box { width: 300px; height: 140px; margin: 20px auto; box-shadow: 1px 1px 3px #999999; } .box1 { background-color: #2ecc71; } .box2 { background-color: #f1c40f; } .box3 { background-image: linear-gradient(to bottom, #2ecc71, #f1c40f); } .block { height: 134px; background-repeat: no-repeat; background-position: 50% 50%; }

What didn’t you like in this task?

Thanks! We’ll fix everything at once!

The code has changed, click “Refresh” or turn autorun on.

You’ve gone to a different page

Click inside the mini-browser to shift the focus onto this window.

100%
Goalscompleted
0
    1. Set the background image cat_cage_8.png to the elements with the class block.
    2. Then assign them the other image cat_cage_8_no_mate.png without an outline.

    Cookies ∙ Privacy ∙ License Agreement ∙ About ∙ Contacts ∙ © HTML Academy OÜ, 2019−2025

    VISAMastercard

    Log in

    or

    Forgot your password?

    Sign up

    Sign up

    or
    Log in

    Restore access

    Have you forgotten your password or lost access to your profile? Enter your email connected to your profile and we will send you a link to restore access.

    Forgot to connect your email to the profile? Email us and we’ll help.