If you want to optimize for high DPI displays, you can utilize media queries like the following example:
@media only screen and (min-device-pixel-ratio: 2) {
/* CSS for high-DPI displays */
}
It's important to note that this query will target any device that meets the specified ratio.
To specifically target Retina displays, you may need to customize your media query further. Here is an approach suggested by Chris Coyier:
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
/* CSS for Retina displays */
}
Various targeting methods have varying levels of browser support, so it's beneficial to be familiar with multiple techniques.
If there are numerous devices meeting the criteria, consider adding additional conditions to refine your targeting.
For instance, to target specific Retina iPhone models like the 5/5S/5C, you could use the following:
@media (-webkit-min-device-pixel-ratio: 2) and (width:640px) and (orientation:portrait) {
/* CSS for specific Retina iPhones */
}
@media (-webkit-min-device-pixel-ratio: 2) and (width:1136px) and (orientation:landscape) {
/* CSS for specific Retina iPhones */
}
However, it's generally advised against targeting individual devices as it can become a never-ending task.