Archive for tag 'tools'

How to create website icons in any color you want

For the latest template that I released, Basic Profile, I made an alternate version which included a set of icons that matched the colorscheme of the template. Since one of the most common modifications that template users want to do is to change the link colors, I want to show you how you can modify the icons to match any color you want your Basic Profile-based website to have.

The icon set: Iconza.com

The icons used in the Basic Profile (alt) template are taken from iconza.com, which offers a set of 119 icons that can be customized using a color selection tool and then downloaded and used with a Creative Commons Attribution license (meaning that a to iconza.com is required if you use their icons). To customize the icon set, start by going to the iconza.com website by clicking the image below.

Step 1: Select your color

The first thing you will see is the set of icons in a default color. You can choose between a number of colors, or use the color selection box to provide a color using a hexadecimal value. For the Basic Profile (alt) template I used #239a23 which creates green icons. If you want to create a set of blue icons, for example using my classic blue color from the andreas01 template, click the red box above the icons beside the “Color” label and enter the hex value #467aa7.

Step 2: Download the icon set

Once you have selected a color, review the icons to make sure that they look nice with the color you have selected and the click the “Download all icons” button below the icons.

Step 3: Extract the .zip and edit the CSS

When the download finishes, extract the .zip you just downloaded to the /images/icons/ folder of the Basic Profile (alt) template to overwrite the icon set that is included with the template. If you have edited the link colors in the basic-profile-alt.css file and changed the default color (#239a23) to #467aa7, you can now review the changes in your web browser. If you haven’t edited the CSS yet, the changes needed to be made in the CSS are on the following two lines:

[css] a {color:#239a23; text-decoration:none;}
h1 a {color:#239a23; text-transform:none;}
[/css]

Edit the color value to make the lines look like this:

[css] a {color:#467aa7; text-decoration:none;}
h1 a {color:#467aa7; text-transform:none;}
[/css]

…and you are done.

Step 4: Review the changes

The template should now look like this:

As with the icon set included by default, you can modify what images are shown to each menu option by editing the .icon classes in the CSS, and the corresponding classes on each menu list item. You may also want to replace the default logo with an image of your own that matches the link and icon colors. If you want to know more about creating a custom logo for the Basic Profile template, post a comment and I may write a separate post on that topic.

Thanks to iconza.com for the excellent icons and the great customization tool, and for allowing site owners to use the icon set for free!

How to keep the CSS code clean

When I work with HTML, CSS, PHP or any other code or scripting language, I always try to keep the code in order to make sure it will remain easy to get into for future updates. Well-structured code makes it easier to spot errors, and also easier to get an idea of what the design will look like in the browser. I tend to stick to a common formatting that I think works well for me, and it is the one I use in my website templates. But during the building and editing process it can be hard to keep the details in order. That is why I usually run the finished code through a tool that formats it in a good way before I publish a new template. My favorite tool for organizing the CSS is CSS Tidy. In this post, I will explain how I use CSS Tidy to format my CSS.

Step 1: Copy the CSS from the stylesheet file

For this example, I will use a part of the CSS from this site. The CSS output of andreasviklund.com is minimized to remove unnecessary whitespace. It reduces the load time, but it makes code very hard to read. Here is the code I will want to clean:

[css] input{width:80px !important;font-family:Verdana,Tahoma,sans-serif;margin-left:5px;font-size:0.9em}
#wpf-wrapper{font-size:1.1em !important}#shareicons{margin-bottom:18px;text-align:left}#shareicons
a{width:48px;height:48px;margin:0 12px;border:0;opacity:50%}#shareicons a:hover{border:0;
opacity:100%}div.wpcf7{margin:0;padding:0}div.wpcf7-response-output{margin:2em 0.5em 1em;
padding:0.2em 1em}div.wpcf7-mail-sent-ok{border:2px solid #398f14}div.wpcf7-mail-sent-ng{border:
2px solid #f00}div.wpcf7-spam-blocked{border:2px solid #ffa500}div.wpcf7-validation-errors
{border:2px solid #f7e700}span.wpcf7-form-control-wrap{position:relative}
[/css]

That looks like a mess, really.

Step 2: Paste the code into CSS Tidy

Go to CSS Tidy and paste the copied code into the “CSS Input” field. You can also use an URL to a CSS file hosted online instead of copying the code.

Step 3: Select format and settings

In the “Code layout” field, there are a couple of different settings for the code output, called “Compression”. It defines what the output will look like, and higher compression means a smaller file with a reduced readability. The code above is similar to the highest compression. I select “High” as my starting point in this example.

As for settings, there are several options for how the code you have entered will be handled. You can choose to sort selectors (which is not recommended), sort properties, convert the code to shorthand format – for example get CSS Tidy to output “margin:10px auto;” if you have written “margin-top:20px; margin-right:auto; margin-bottom:20px; margin-left:auto;”. This is a screenshot of the settings I use:

Step 4: Process the CSS

With the CSS in place, the format selected and the settings entered, it is time to press the “Process CSS” button. CSS Tidy then cleans the code, and tells you what optimizations that have been made. In this case, the following things were changed or commented:

  1. Optimised number: Changed “0.9em” to “.9em”
  2. Invalid property in CSS2.1: opacity
  3. Invalid property in CSS2.1: opacity
  4. Optimised number: Changed “0.5em” to “.5em”
  5. Optimised number: Changed “0.2em” to “.2em”
  6. Optimised color: Changed “#f00″ to “red”
  7. Optimised color: Changed “#ffa500″ to “orange”

Review the result

This is the final result after processing, and now the format looks much more familiar. And much easier to read.

[css] input{font-family:Verdana,Tahoma,sans-serif;font-size:.9em;margin-left:5px;width:80px!important;}
#wpf-wrapper{font-size:1.1em!important;}
#shareicons{margin-bottom:18px;text-align:left;}
#shareicons
a{border:0;height:48px;margin:0 12px;opacity:50%;width:48px;}
#shareicons a:hover{border:0;opacity:100%;}
div.wpcf7{margin:0;padding:0;}
div.wpcf7-response-output{margin:2em .5em 1em;padding:.2em 1em;}
div.wpcf7-mail-sent-ok{border:2px solid #398f14;}
div.wpcf7-mail-sent-ng{border:2px solid red;}
div.wpcf7-spam-blocked{border:2px solid orange;}
div.wpcf7-validation-errors{border:2px solid #f7e700;}
span.wpcf7-form-control-wrap{position:relative;}
[/css]

Remember to always double-check the processed code to make sure it works as the original code, and always keep backups of older versions.

Other formats for higher readability

Make sure to try the other format options as well, they may suit you better. This is an example of the “Standard” layout:

[css] input {
font-family:Verdana,Tahoma,sans-serif;
font-size:.9em;
margin-left:5px;
width:80px!important;
}

#wpf-wrapper {
font-size:1.1em!important;
}
[/css]

That is a quite common way to make the CSS even easier to work with. I prefer to keep it more compact to avoid scrolling, but it is a matter of taste and personal preference.

Final words about CSS Tidy

I like this tool, and I like the fact that it is not just available through the link above. You can also download the script and host it on your own server, or even build it into your website scripts to automatically format the CSS output at runtime. You can also create your own format styles if you want a specific format for the output. For more information, see the CSS Tidy website (which happens to be built using the andreas01 template, by the way!).

Also keep in mind that CSS Tidy is NOT a validator, only a formatting tool. To make sure that your code validates, always run it through a CSS validator as well.

Try the new TemplateBuilder tool!

Today I am launching a new feature on andreasviklund.com, an online tool for building (and within a near future, publishing) complete websites out of the templates found here. It is called the TemplateBuilder, and it is free to use. It can be considered a beta launch since some features are not yet in place. But the tool is still fully functional, and I think it will be the most useful addition to this site so far. Basically, it allows anyone to build websites using templates – without any need to edit any HTML.

I will write a lot more about this tool during the next couple of weeks, to explain how to use it and what the plans there are for future features. For now, you are very welcome to give it a test run. Go to templatebuilder.andreasviklund.com to get started! If you have any questions, don’t hesitate to write me an e-mail.

Exploring Dreamweaver CS5

After posting the Building your first website using a free website template tutorial, where I used the Notepad++ code editor to turn the Variant Duo template into a three-page website, I got several questions and requests about how the same process would work if I would use a visual editor instead of a code editor. One of the points with the template was to explain the concept of code editing, and to show that learning (X)HTML can be done in small steps if wanted. But as with all kinds of projects, it is a matter of personal preference if you want to work with the code or with a visual editor. I prefer working with the code directly since it gives me a better overview and helps me keep the code valid and optimized. As mentioned in the tutorial, visual editors are not always outputting good code – and there is a lot to gain from following web standards and keeping the code as simple as possible.

But there are of course good visual editors available as well, and since several readers asked specifically for tips about Adobe Dreamweaver, I decided to take a closer look at how the current version, Dreamweaver CS5, works. I am currently experimenting with it to see how the visual editor in Dreamweaver handles the code output, and I am planning to write a tutorial post (or possibly a series of posts) about using Dreamweaver to turn a template into a website. From what I have seen so far it looks really promising, but as a commercial editor (priced $399 on adobe.com), it may not be a good first editor for beginners. Still, it is a widely used editor so I will write more about it as soon as I have got more familiar with it.

The Basic Reader (3-col edition) template as it looks in Adobe Dreamweaver CS5