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 common export labels. 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.

The PNG-8 examples in this task, like GIF images, use transparency in which each pixel is either completely transparent or completely opaque. Indexed-color PNG can also store partial transparency for palette entries.

When exporting an image with transparency and a matte, set the matte to the same color as the page background. In Photoshop, choose the “Matte” option when saving the image. Without a matte, the image may have jagged 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 image with a matte may show a visible border.

Why use PNG instead of GIF? PNG is an open format that uses lossless compression. It is a useful alternative for static graphics like these.

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 a matte.

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

    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.