{"id":1679,"date":"2011-06-07T21:24:32","date_gmt":"2011-06-07T11:24:32","guid":{"rendered":"https:\/\/eisabainyo.net\/weblog\/?p=1679"},"modified":"2011-06-07T21:39:36","modified_gmt":"2011-06-07T11:39:36","slug":"how-to-use-hi-res-images-for-web-apps-in-iphone4","status":"publish","type":"post","link":"https:\/\/eisabainyo.net\/weblog\/2011\/06\/07\/how-to-use-hi-res-images-for-web-apps-in-iphone4\/","title":{"rendered":"How to use hi-res images in web apps for iPhone4"},"content":{"rendered":"<p>If you have been developing websites and web apps for mobile, you may have noticed that the images are not very crisp on iPhone 4.  The Retina display on iPhone 4 is the sharpest, most vibrant, highest-resolution phone screen ever but you need to know how to utilise it.  The images you use on the websites need to be high resolution (at least 2 times bigger than the normal size) in order for them to look sharp on iPhone 4.  The good news is, it is possible to use hi-res images in web apps \/ websites for iPhone4 without using any javascript.<\/p>\n<p><strong>For images that are displayed via &lt;img&gt; tags:<\/strong><\/p>\n<p>Save the image in x2 resolution.  For example, if your logo is 50x50 pixels, make sure it is saved as 100x100 pixels (Resolution: 144 in Photoshop)<\/p>\n<p>And in your HTML source code, make sure to specify height and width attributes for the &lt;img&gt; tag like below:<\/p>\n<p><code>&lt;img src=&quot;images\/logo.png&quot; alt=&quot;Web Development Blog&quot; width=&quot;50&quot; height=&quot;50&quot; \/&gt;<\/code><\/p>\n<p><strong>For images that are displayed as background images via CSS:<\/strong><\/p>\n<p>This is a bit trickier, because you don't want to use hi-res images for iPhone 3 or Android or other mobile browsers.  To target just iPhone 4, add the following line of code in the &lt;head&gt; section of your page right after the normal CSS include.<\/p>\n<p><code>&lt;link rel=&quot;stylesheet&quot; href=&quot;css\/common.css&quot; \/&gt;<\/code><\/p>\n<p><code>&lt;link rel=&quot;stylesheet&quot; href=&quot;css\/hires.css&quot; media=&quot;only screen and (-webkit-min-device-pixel-ratio: 2)&quot;\/&gt;<\/code><\/p>\n<p>And for every image, you need to save 2 versions - one for the regular view and the other one for the hi-res view.  For example, button-signup.jpg and button-signup2x.jpg.  The button-signup.jpg will be 50x20 pixels whereas the button-signup2x.jpg will be 100x40 pixels.  <\/p>\n<p>In your hires.css file, you will have something like the following:<\/p>\n<p><code>#signup { background: transparent url(..\/images\/button-signup2x.jpg) 0 0 no-repeat;  background-size: 50px 20px; }<\/code><\/p>\n<p>Note that the background-size is the size of the image in regular view.  This will allow the background image to be shrunk so it fits within the specified element. The background-size property is a CSS3 property and it lets you specify the size of background images. <\/p>\n<p>And in your style.css, you will have:<\/p>\n<p><code>#signup { background: transparent url(..\/images\/button-signup.jpg) 0 0 no-repeat; }<\/code><\/p>\n<p>And that's all! <\/p>\n","protected":false},"excerpt":{"rendered":"<p>If you have been developing websites and web apps for mobile, you may have noticed<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2,11],"tags":[],"class_list":["post-1679","post","type-post","status-publish","format-standard","hentry","category-css","category-tutorials"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to use hi-res images in web apps for iPhone4 | Tech Leadership Advice &amp; Resources<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/eisabainyo.net\/weblog\/2011\/06\/07\/how-to-use-hi-res-images-for-web-apps-in-iphone4\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to use hi-res images in web apps for iPhone4 | Tech Leadership Advice &amp; Resources\" \/>\n<meta property=\"og:description\" content=\"If you have been developing websites and web apps for mobile, you may have noticed\" \/>\n<meta property=\"og:url\" content=\"https:\/\/eisabainyo.net\/weblog\/2011\/06\/07\/how-to-use-hi-res-images-for-web-apps-in-iphone4\/\" \/>\n<meta property=\"og:site_name\" content=\"Tech Leadership Advice &amp; Resources\" \/>\n<meta property=\"article:published_time\" content=\"2011-06-07T11:24:32+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2011-06-07T11:39:36+00:00\" \/>\n<meta name=\"author\" content=\"Isabel Nyo\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Isabel Nyo\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/eisabainyo.net\/weblog\/2011\/06\/07\/how-to-use-hi-res-images-for-web-apps-in-iphone4\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/eisabainyo.net\/weblog\/2011\/06\/07\/how-to-use-hi-res-images-for-web-apps-in-iphone4\/\"},\"author\":{\"name\":\"Isabel Nyo\",\"@id\":\"https:\/\/eisabainyo.net\/weblog\/#\/schema\/person\/33457dd19f1ad9bbd4b0cb50c54dfcab\"},\"headline\":\"How to use hi-res images in web apps for iPhone4\",\"datePublished\":\"2011-06-07T11:24:32+00:00\",\"dateModified\":\"2011-06-07T11:39:36+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/eisabainyo.net\/weblog\/2011\/06\/07\/how-to-use-hi-res-images-for-web-apps-in-iphone4\/\"},\"wordCount\":338,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/eisabainyo.net\/weblog\/#\/schema\/person\/33457dd19f1ad9bbd4b0cb50c54dfcab\"},\"articleSection\":[\"CSS\",\"Tutorials\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/eisabainyo.net\/weblog\/2011\/06\/07\/how-to-use-hi-res-images-for-web-apps-in-iphone4\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/eisabainyo.net\/weblog\/2011\/06\/07\/how-to-use-hi-res-images-for-web-apps-in-iphone4\/\",\"url\":\"https:\/\/eisabainyo.net\/weblog\/2011\/06\/07\/how-to-use-hi-res-images-for-web-apps-in-iphone4\/\",\"name\":\"How to use hi-res images in web apps for iPhone4 | Tech Leadership Advice &amp; Resources\",\"isPartOf\":{\"@id\":\"https:\/\/eisabainyo.net\/weblog\/#website\"},\"datePublished\":\"2011-06-07T11:24:32+00:00\",\"dateModified\":\"2011-06-07T11:39:36+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/eisabainyo.net\/weblog\/2011\/06\/07\/how-to-use-hi-res-images-for-web-apps-in-iphone4\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/eisabainyo.net\/weblog\/2011\/06\/07\/how-to-use-hi-res-images-for-web-apps-in-iphone4\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/eisabainyo.net\/weblog\/2011\/06\/07\/how-to-use-hi-res-images-for-web-apps-in-iphone4\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/eisabainyo.net\/weblog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to use hi-res images in web apps for iPhone4\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/eisabainyo.net\/weblog\/#website\",\"url\":\"https:\/\/eisabainyo.net\/weblog\/\",\"name\":\"Career Resources for Professionals in Tech\",\"description\":\"Books, worksheets, templates, frameworks and other useful resources for Chief Technology Officers (CTOs), VPs of Engineering &amp; Technology Directors\",\"publisher\":{\"@id\":\"https:\/\/eisabainyo.net\/weblog\/#\/schema\/person\/33457dd19f1ad9bbd4b0cb50c54dfcab\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/eisabainyo.net\/weblog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\/\/eisabainyo.net\/weblog\/#\/schema\/person\/33457dd19f1ad9bbd4b0cb50c54dfcab\",\"name\":\"Isabel Nyo\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/eisabainyo.net\/weblog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/3d4b1a4e0f425adb39b242b0d62c5fac07c82f8314a24631f1d16f47bdf006d8?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/3d4b1a4e0f425adb39b242b0d62c5fac07c82f8314a24631f1d16f47bdf006d8?s=96&d=mm&r=g\",\"caption\":\"Isabel Nyo\"},\"logo\":{\"@id\":\"https:\/\/eisabainyo.net\/weblog\/#\/schema\/person\/image\/\"},\"description\":\"My interests: Web Development, Web Design, Web Applications, Web 2.0, AJAX, Search Engine Optimisation, Latest Technologies and more..\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to use hi-res images in web apps for iPhone4 | Tech Leadership Advice &amp; Resources","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/eisabainyo.net\/weblog\/2011\/06\/07\/how-to-use-hi-res-images-for-web-apps-in-iphone4\/","og_locale":"en_US","og_type":"article","og_title":"How to use hi-res images in web apps for iPhone4 | Tech Leadership Advice &amp; Resources","og_description":"If you have been developing websites and web apps for mobile, you may have noticed","og_url":"https:\/\/eisabainyo.net\/weblog\/2011\/06\/07\/how-to-use-hi-res-images-for-web-apps-in-iphone4\/","og_site_name":"Tech Leadership Advice &amp; Resources","article_published_time":"2011-06-07T11:24:32+00:00","article_modified_time":"2011-06-07T11:39:36+00:00","author":"Isabel Nyo","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Isabel Nyo","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/eisabainyo.net\/weblog\/2011\/06\/07\/how-to-use-hi-res-images-for-web-apps-in-iphone4\/#article","isPartOf":{"@id":"https:\/\/eisabainyo.net\/weblog\/2011\/06\/07\/how-to-use-hi-res-images-for-web-apps-in-iphone4\/"},"author":{"name":"Isabel Nyo","@id":"https:\/\/eisabainyo.net\/weblog\/#\/schema\/person\/33457dd19f1ad9bbd4b0cb50c54dfcab"},"headline":"How to use hi-res images in web apps for iPhone4","datePublished":"2011-06-07T11:24:32+00:00","dateModified":"2011-06-07T11:39:36+00:00","mainEntityOfPage":{"@id":"https:\/\/eisabainyo.net\/weblog\/2011\/06\/07\/how-to-use-hi-res-images-for-web-apps-in-iphone4\/"},"wordCount":338,"commentCount":0,"publisher":{"@id":"https:\/\/eisabainyo.net\/weblog\/#\/schema\/person\/33457dd19f1ad9bbd4b0cb50c54dfcab"},"articleSection":["CSS","Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/eisabainyo.net\/weblog\/2011\/06\/07\/how-to-use-hi-res-images-for-web-apps-in-iphone4\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/eisabainyo.net\/weblog\/2011\/06\/07\/how-to-use-hi-res-images-for-web-apps-in-iphone4\/","url":"https:\/\/eisabainyo.net\/weblog\/2011\/06\/07\/how-to-use-hi-res-images-for-web-apps-in-iphone4\/","name":"How to use hi-res images in web apps for iPhone4 | Tech Leadership Advice &amp; Resources","isPartOf":{"@id":"https:\/\/eisabainyo.net\/weblog\/#website"},"datePublished":"2011-06-07T11:24:32+00:00","dateModified":"2011-06-07T11:39:36+00:00","breadcrumb":{"@id":"https:\/\/eisabainyo.net\/weblog\/2011\/06\/07\/how-to-use-hi-res-images-for-web-apps-in-iphone4\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/eisabainyo.net\/weblog\/2011\/06\/07\/how-to-use-hi-res-images-for-web-apps-in-iphone4\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/eisabainyo.net\/weblog\/2011\/06\/07\/how-to-use-hi-res-images-for-web-apps-in-iphone4\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/eisabainyo.net\/weblog\/"},{"@type":"ListItem","position":2,"name":"How to use hi-res images in web apps for iPhone4"}]},{"@type":"WebSite","@id":"https:\/\/eisabainyo.net\/weblog\/#website","url":"https:\/\/eisabainyo.net\/weblog\/","name":"Career Resources for Professionals in Tech","description":"Books, worksheets, templates, frameworks and other useful resources for Chief Technology Officers (CTOs), VPs of Engineering &amp; Technology Directors","publisher":{"@id":"https:\/\/eisabainyo.net\/weblog\/#\/schema\/person\/33457dd19f1ad9bbd4b0cb50c54dfcab"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/eisabainyo.net\/weblog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/eisabainyo.net\/weblog\/#\/schema\/person\/33457dd19f1ad9bbd4b0cb50c54dfcab","name":"Isabel Nyo","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/eisabainyo.net\/weblog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/3d4b1a4e0f425adb39b242b0d62c5fac07c82f8314a24631f1d16f47bdf006d8?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/3d4b1a4e0f425adb39b242b0d62c5fac07c82f8314a24631f1d16f47bdf006d8?s=96&d=mm&r=g","caption":"Isabel Nyo"},"logo":{"@id":"https:\/\/eisabainyo.net\/weblog\/#\/schema\/person\/image\/"},"description":"My interests: Web Development, Web Design, Web Applications, Web 2.0, AJAX, Search Engine Optimisation, Latest Technologies and more.."}]}},"_links":{"self":[{"href":"https:\/\/eisabainyo.net\/weblog\/wp-json\/wp\/v2\/posts\/1679","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/eisabainyo.net\/weblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/eisabainyo.net\/weblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/eisabainyo.net\/weblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/eisabainyo.net\/weblog\/wp-json\/wp\/v2\/comments?post=1679"}],"version-history":[{"count":8,"href":"https:\/\/eisabainyo.net\/weblog\/wp-json\/wp\/v2\/posts\/1679\/revisions"}],"predecessor-version":[{"id":1681,"href":"https:\/\/eisabainyo.net\/weblog\/wp-json\/wp\/v2\/posts\/1679\/revisions\/1681"}],"wp:attachment":[{"href":"https:\/\/eisabainyo.net\/weblog\/wp-json\/wp\/v2\/media?parent=1679"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/eisabainyo.net\/weblog\/wp-json\/wp\/v2\/categories?post=1679"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/eisabainyo.net\/weblog\/wp-json\/wp\/v2\/tags?post=1679"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}