HTML Academy
The PNG-8 Format
Introduction to Backgrounds12/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
The GIF Format
  • Sign up
  • Log in

Loading…
Everything will be ready in few seconds

  • Theory
  • Theory
  • Comments

PNG-24 format

PNG-24 is a great format. It is well suited for diagrams, drawings, graphs, text, as well as for complex multi-color images, since it supports an almost unlimited number of colors.

For photos, it is usually inferior to JPEG in terms of file size, but superior in terms of image quality. But sometimes the difference in file size is so insignificant that there is no reason not to go with PNG.

The main plus of PNG-24 is that it has full support for semi-transparency, which is not available in any other format. Therefore, when you in your web development work need to lay out complex backgrounds, graphic elements with complex shadows, and so on, there is simply no alternative to PNG-24.

A long time ago, IE had a problem with semi-transparent PNG support, but there are no such problems in later versions of IE (8+).

Compare the PNG-8 of a cat with outline from the previous assignment with the PNG-24 of a cat from this assignment. Pay particular attention to how their edges look against the yellow and gradient blocks.

Some layout designers are opting to discontinue using PNG-8 in favor of using only PNG-24 instead.

Comments

  • index.html
  • style.css
HTML
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>PNG-24 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. Assign the background image cat_cage.png to the elements with the class block.

    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.