Rules to Better Websites - Graphics
Framework pages (i.e., user controls and common layout files) should have width and height properties specified for all images that are used. This means that the page's layout will be rendered correctly while loading and when the user has images turned off in their browser.
Images that have a height and width property set can improve your page’s load times by a few milliseconds. However, this will cause problems for any responsive behaviour of the page and should be used when appropriate. It is exceedingly unusual for an image in the site layout to not be placed using CSS, so it’s likely if this rule applies to you, you should switch to CSS and background-property.
<img src="TopBar_Row1_Col2.gif" />
Figure: Bad Example - User controls does not contain width and height properties
<img src="TopBar_Row1_Col2.gif" width="86" height="20" />
Figure: Good Example - User controls contains width and height propertiesWe have a program called SSW Code Auditor to check for this rule.
Never use bitmap images (.BMP format) on your website or in emails. BMP is an uncompressed format, and typically has an unlimited color palette. This results in unnecessarily large filesizes, which makes it unsuitable for pretty much everything.
As an alternative, the most ideal format for Internet-ready lossless images is PNG.
We have a program called SSW Code Auditor to check for this rule.
Many sites have screenshot galleries that offer a list of all the screens within an application, and an option to enlarge them. There's just one problem: you can't see what they contain!
What we suggest as an alternative is to have one large image - full size - (and possibly a list of descriptions) to allow users to have a large screenshot to view right from the get go. This might look something like:
Our Code Auditor User Guide provides a good example for this rule.
In the case of content (unlike a site's framework files), specifying the width and heightproperties for images on your web pages can sometimes turn out to be more trouble than it's worth, particularly if the image is likely tobe changed a few times. Adding fixed widths to your images also destroys your content on any responsive websites.
As a result, we have made a rule that content pages should not have the image dimensions specified in HTML.
We do have one exception to this rule: any HTML content that is to be sent out via email, as Outlook blocks images by default andrenders them as placeholders with very lengthy alternate text. The page is invariably stretched to widths that make thecontents of the message somewhat unreadable.
<img src="MyPic.gif" width="93" height="25">
Figure: Bad Example - Including the width and height properties for content images
Figure: Good Example - Exclude width and height properties for content imagesWe have a program called SSW Code Auditor to check for this rule.
A Favicon is a small image file included on professionally developed sites. The favicon reflects the look and feel of the website or the organizations' visual identity.
Which formats and sizes to use?
The format of the image must be one of PNG (a W3C standard), GIF, or ICO. You can export your favicon in all necessary sizes on Favicon Generator website.
How to implement the favicon?
- Copy your company's favicon to the root of the site
- Add the highlighted code below inside the <HEAD> tags in your HTML
<head> <title>Page Title</title> <link rel="shortcut icon" href="/images/favicon.ico" type="image/x-icon" /> </head>
Figure: One line of HTML lets you add your company's icon to your web page ** **
This works for most websites, including ASPX WebForms, MVC and WordPress.
Every time you add an image to your content, make sure it:
- Has at least 800px width (except for logos, icons, and profile images)
- Is readable if it has any text on it
- Looks consistent with others on the same page
- (optional) Is not in dark-mode - Light background images look better most of the times
Developers should never do design work. A bad design can be dangerous for the project. It's the web designer’s responsibility to create the overall look and feel of the website and define anything related to layout, typography, color selection, branding and overall consistency. The designer is also responsible for any image processing, web optimization and browser/platform testing of the website.
If you've ever wondered why the formats of graphics on the web differ from each other, you're not alone. With SVGs, PNGs, and JPGs, it's hard to know which format you should use in a particular situation. Don't simply add any image that looks alright, it is very important to know the advantages and disadvantages of each format for optimization.
Screenshots are a very important part of websites these days. Be careful to avoid unnecessary toolbars and taskbars in screen shots.
- Use a region screen shot if appropriate (however the URL is generally helpful in most browser screen shots)
- Go full screen e.g. F11 in Internet Explorer, then <Alt>+<Print>
- Always have the 'Auto-hide the taskbar' option checked
In line with the statement above, all photographs should be stored in JPG format. JPG rationalizes the quality of the image by averaging out the colors in segments of the image that it defines. To see an example of this working, try lowering the quality of a JPG to minimum quality.
PNG is an alternative to JPG, heavily endorsed by some circles, mainly because of its open source and non-commercial nature.
- Alpha blending (24 bit transparency map support)
- Unlimited and limited color palettes. This makes it a good alternative to BMP.
- Multiple CRCs so that file integrity can be checked without viewing
However, it has rather poor file compression and should be used sparingly.
Line art graphics and anything with well defined shapes (logos, vector illustrations, e.t.c.) must be saved in SVG format.
Some of SVG format advantages are:
- Written in XML
- Official W3C graphics standard
- Accessible for people with visual disabilities
- Can be animated
- No pixelation
- Small file size
- Supports transparency
- Text can be selected, copied, spoken by the computer, and indexed by search engines.
When want to show an image from the web on your website, the easiest way is to just copy the image's path and add it. This is not a good idea as the original host of the image can delete it, which will cause a broken image in your website.
The right way to do this is to copy the image locally and upload to your own server, so you have total control over the image.
<img src="https://some-external-url.com/images/open-extension.png" alt="Open extension"> <dd>Figure: Open extension</dd>
Figure: Bad example - using an external URL as image source. The image can be edited or deleted and there is nothing you can do about it
<img src="https://ssw.com.au/images/open-extension.png" alt="Open extension"> <dd>Figure: Open extension</dd>
Figure: Good example - Image is hosted internally. You have control over the image
Note: For copyrighted images, it is important to always mention the source.
Image files are outside the realm of most database developers mind sets. So I've seen many very messy websites that have duplicate images all over the place. You only need an image in one place in your web site. The rule is that if it is used once, it goes in the associated directory - e.g. /ssw/Company/Images OR if it is used more than once, the image is moved to the root images directory - e.g. /ssw/Images. One of benefits of avoiding duplicate images is speed up web surfing for your users.
A nice looking image can be harmful to your website if it's not optimized. It's important to optimize images for the web because the fewer bytes the browser has to download, the less bandwidth the client uses, and the faster the browser can download and render your content on the screen.
The first thing is to save your graphics in the right format and size. After that, you should run an image optimizer.
Some tips and techniques to keep in mind as you work on optimizing your images:
- Don't be afraid to dial down the "quality" settings if the results are very good and byte savings are significant
- Remove unnecessary image metadata like geo information, camera information, and so on.
- Use automated tools to ensure that all of your images are always optimized. E.g.: http://optimizilla.com
If your website is running on WordPress you should install and activate the plugin WP Smush. It scans every image you upload – or have already added to your site – cuts all the unnecessary data and scales it for you before adding it to your media library.
It is important to sensibly name your images. We don't use "img" (in the same way we don't use "tbl" for tables).
However, for special types of images we do include a prefix.
Image Type Prefix Example Banner ban banSSW.gif Icon ico icoSSW.ico Screenshot Screen ScreenCodeAuditorMainWindow.gif
Never stretch small, low-resolution photos to make it fill up the space. This degrades the resolution and the image will appear very coarse and granular on the projection screen.
The quality of your images is a subconscious message to your audience. If you use low quality pictures, then you unintentionally suggest the same message about your product.
For this reason, we encourage you to choose only high quality photos and to avoid cartoons and word art.
A sprite is an image that has all of your other images inside of it, so if your sprite has 5 images, you’d be getting rid of 4 HTTP requests and speeding your site’s loading time up by the time for each of those 4 requests latency. You will use CSS selectors for each link to display only a portion of the image sprite - effectively showing just the image you need.
The benefits to use CSS image sprites are:
- to save bandwidth
- to reduce HTTP server requests
- to speed up page load times
Ensure that the file size of your master image isn't greater than the sum of its pieces.
Many people will simply "plonk" an image onto a web page in between or next to a block of text. This interrupts the flow of the page and gives a disjointed, unprofessional impression.
A good technique is to set a CSS style to images. This style will be consistent and easy to be used by any person who might edit the website content.
It's also important to choose the correct semantic formatting for images. Different HTML codes might give the same look and feel, but the best way to add images to your page is using <dl> , <dt> and <dd> tags.
<div class="badImage"> <img src="Images/imageWithoutStyles.jpg" alt="Image without styles"> <span>Figure: Bad Example - The image has no styles</span> </div>
Figure: Bad Example - Inserting images and captions inside <div> tags
<img src="Images/imageWithoutStyles.jpg" alt="Image without styles"> <dd>Figure: Bad Example - The image has no styles</dd>
Figure: Good Example - Using the <dl>, <dt> and <dd> tags for images
Using text rather than images has multiple advantages:
- Downloads faster - a users patience extends to about 7 seconds.
- Cheaper to update - a simple find and replace.
- Discoverable by search engines - if people can't get to your site, what's the point of it being there?
- Readable on an iPhone - Images will either be resized or require scrolling, which would create difficulties for readability.
<img src="Images/Heading_Welcome.gif">Figure: Bad Example - using image for text header<h1>Welcome to My Page</h1>Figure: Good Example - this text can be easily rendered by the browser and recognized by search engine