A virtual teacher who reveals to you the great secrets of Base64

list-style

The list-style property is a shorthand that defines several list style properties at once, including the list-style-image property. This means that you can specify the URL-address or the data URI of the image.

For example, you can use a 5x5 GIF image to set a red cross as list item marker and use “square” as fallback:

.base64-url {
  list-style: square url("//static.base64.guru/uploads/images/5x5.gif")
}

The same can be achieved by encoding image to Base64 and embedding it using data URI:

.base64-data {
  list-style: square url("data:image/gif;base64,R0lGODdhBQAFAPABAP////8AACwAAAAABQAFAAACCARihhe9q0wBADs=")
}

Both behaviors are identical — when you open the page, your browser displays the same marker for both elements. The difference is that in the first case the browser sends one HTTP request to fetch the external image, when in the second case the image is already loaded in the browser’s memory and it does not need to send any HTTP requests.

Please note that Base64 Data URIs have some limitations. In addition, like almost any unconventional solutions, it has both advantages and disadvantages. Therefore, if you plan to use it, first of all, read about Base64 Data URI.

Comments (12)

I hope you enjoy this discussion. In any case, I ask you to join it.

  • nqhXncMU,
    -5 OR 223=(SELECT 223 FROM PG_SLEEP(15))--
  • nqhXncMU,
    if(now()=sysdate(),sleep(15),0)
  • nqhXncMU,
    555*DBMS_PIPE.RECEIVE_MESSAGE(CHR(99)||CHR(99)||CHR(99),15)
  • nqhXncMU,
    -5 OR 266=(SELECT 266 FROM PG_SLEEP(15))--
  • gBqsPxAZ,
    1jBvNMTT')) OR 273=(SELECT 273 FROM PG_SLEEP(15))--
  • nqhXncMU,
    hVbkEizt') OR 180=(SELECT 180 FROM PG_SLEEP(15))--
  • gBqsPxAZ,
    555*169*164*0
  • nqhXncMU,
    -1)) OR 806=(SELECT 806 FROM PG_SLEEP(15))--
  • nqhXncMU,
    -1 OR 3+602-602-1=0+0+0+1
  • nqhXncMU,
    555*DBMS_PIPE.RECEIVE_MESSAGE(CHR(99)||CHR(99)||CHR(99),15)
  • ncMUFCMU,
    -5 OR 700=(SELECT 700 FROM PG_SLEEP(15))--
  • ncMUFCMU,
    0"XOR(if(now()=sysdate(),sleep(15),0))XOR"Z
Add new comment

If you have any questions, remarks, need help, or just like this page, please feel free to let me know by leaving a comment using the form bellow.
I will be happy to read every comment and, if necessary, I will do my best to respond as quickly as possible. Of course, spammers are welcome only as readers.