What is Apple Touch Icon?
An Apple touch icon is a file that is used to customize an icon for a website when it is added to the home screen of an iOS device, such as an iPhone or iPad. The touch icon is displayed on the device's home screen when the user saves the website to their home screen and is used to represent the website when it is launched from the home screen. The touch icon should be a square image that is at least 512 x 512 pixels in size and in the .png or .jpg format. To specify the touch icon for a website, you can include a link to the touch icon file in the head of the HTML file for the website, like this:
<link rel="apple-touch-icon" href="/path/to/touch-icon.png">
You can also specify different touch icons for different resolutions and devices by using the sizes attribute and media queries, like this:
<link rel="apple-touch-icon" sizes="180x180" href="/path/to/touch-icon-180.png">
<link rel="apple-touch-icon" sizes="152x152" href="/path/to/touch-icon-152.png">
<link rel="apple-touch-icon" sizes="144x144" href="/path/to/touch-icon-144.png">
- You can specify a precomposed touch icon by using the rel attribute with a value of apple-touch-icon-precomposed, like this:
<link rel="apple-touch-icon-precomposed" href="/path/to/touch-icon.png">
This will prevent the iOS device from applying any additional effects to the touch icon, such as adding a gloss effect.
- You can specify a different touch icon for the home screen when the website is launched in full-screen mode by using the rel attribute with a value of apple-touch-startup-image, like this:
<link rel="apple-touch-startup-image" href="/path/to/startup-image.png">
When a website is launched in full-screen modes, such as a splash screen or a loading indicator, it is very useful to display a different image.
- If you don't specify a touch icon for a website, the iOS device will use the favicon for the website as the touch icon. If the website doesn't have a favicon, the iOS device will use a default icon.
- You can use the apple-touch-icon and apple-touch-icon-precomposed link elements in the head of your HTML file to specify touch icons for a website, but you can also use the link element in the body of your HTML file to specify touch icons for individual pages on a website. It is useful if you want to use different touch icons for different pages on a website.
- You can specify a maskable touch icon by using the rel attribute with a value of mask-icon, like this:
<link rel="mask-icon" href="/path/to/mask-icon.svg" color="#000000">
It will create a mask icon that can be used to create a custom icon for your website when it is added to the home screen of an iOS device. The mask icon should be an SVG file that is at least 512 x 512 pixels in size and has a transparent background.
- You can specify the background color for the mask icon by using the color attribute in the link element. The value of the color attribute should be a valid CSS color value, such as a hex code or a color keyword.
- If you want to specify a different mask icon for different resolutions and devices, you can use the sizes attribute and media queries in the link element, like this:
<link rel="mask-icon" sizes="180x180" href="/path/to/mask-icon-180.svg" color="#000000">
<link rel="mask-icon" sizes="152x152" href="/path/to/mask-icon-152.svg" color="#000000">
<link rel="mask-icon" sizes="144x144" href="/path/to/mask-icon-144.svg" color="#000000">
- The mask icon will be displayed on the home screen of an iOS device in the same way as a touch icon, but it will be displayed with the specified background color and without any additional effects applied by the iOS device.
- You can specify a different touch icon for different devices by using media queries in the link element, like this:
<link rel="apple-touch-icon" sizes="180x180" href="/path/to/touch-icon-180.png" media="(device-width: 320px) and (device-height: 568px) and (-webkit-device-pixel-ratio: 2)">
<link rel="apple-touch-icon" sizes="152x152" href="/path/to/touch-icon-152.png" media="(device-width: 375px) and (device-height: 812px) and (-webkit-device-pixel-ratio: 3)">
<link rel="apple-touch-icon" sizes="144x144" href="/path/to/touch-icon-144.png" media="(device-width: 414px) and (device-height: 736px) and (-webkit-device-pixel-ratio: 3)">
It allows you to specify different touch icons for different device resolutions and pixel densities.
- If you want to specify a different touch icon for different orientations of a device, you can use the orientation media feature in the link element, like this:
<link rel="apple-touch-icon" sizes="180x180" href="/path/to/touch-icon-180-portrait.png" media="(orientation: portrait)">
<link rel="apple-touch-icon" sizes="180x180" href="/path/to/touch-icon-180-landscape.png" media="(orientation: landscape)">
It allows you to specify different touch icons for portrait and landscape orientations of the device.