Friday, September 10, 2010

Things you can do with HTML but not XHTML

News to me...
http://www.sitepoint.com/forums/showthread.php?t=393445
Create parts of the page dynamically with JavaScript while the document is still loading (e.g., using document.write()).

but in XHTML you get CDATA, which is handy...

read this when time... kinda wtf I thought XHTML was just better... maybe its just too late at night and I've forgotten.

more from that article...

Is XHTML supported by all browsers?
No. Only a few mainstream browsers support XHTML, like Opera, Firefox and Safari.

Most importantly, Internet Explorer does not support XHTML at all.

If you follow certain guidelines you can serve XHTML documents as text/html (see below). That means the document will be seen as HTML, which all browsers can handle. Virtually all browsers have a parser bug that ignores the slash in self-closing tags.


Should I use XHTML or HTML?
That depends on who you ask. There are a number of technical issues with this question, which preclude a simple and short answer. In reality, the latest W3C recommendation with widespread support is HTML 4.01. Unless you actually need any of the features that XHTML offers over HTML, there is no technical reason to use XHTML.

In order to actually benefit from using XHTML, you really need to understand the fundamental differences between XHTML and HTML. Such a site will only be available to a small minority of the surfing population, however.

Some web designers and developers prefer XHTML's syntax rules over HTML's. By following certain guidelines, you can use this syntax without technically using XHTML at all (see below). There are a number of potential pitfalls with this approach, but it is a possible way forward for those who absolutely want to type
instead of
.

Cool HTML coding quality checklist / reminder

Good to read through before you start a job if its been awile or check through before you launch a template etc.
http://sweatte.wordpress.com/usability/html-tips/

Friday, September 3, 2010

Make Illustrator cs3 pixel perfect for web design and slicing

Ok every time I get to slicing there is some trouble with Illustrator slices being off and I forget what I did last time to make it right. Here it is.

In General:
Illustrator is more like a drafting program, and can definitely achieve pixel perfection if you set it up right.

When your drawing boxes, think in pixels from the start, and key in the values of your box dimensions as you go. If you resize then, don't randomly free transform, but key in the dimensions, or, free transform using snap to grid/pixel. Its less to clean up later on.

Page grid:
For designing and rough draft stage I like to have my page grid set to:
Preferences > Guides and Grid > Gridline every 60px, subdivisions 6, which gives a 10px grid and works well for the 960grid designs. Snap to grid and 'try' and draw your boxes using whole numbers as you go.

For slicing stage I change it to Gridline every 60px, subdivisions 60. So it is now a 1px x 1px grid.

Before slicing I go through the boxes and make sure all heights and widths and x,y,-co-ordinates are whole numbers, and zoom right in to affirm they are on the pixel boundaries. Sounds laborious but usually there aren't that many things to slice with CSS3 and favouring a minimalist aesthetic.

For boxes with old school drop-shadows of say precisely 3px, it is really important to get pixel perfection,  or drop-shadows will be cut off and boxes misaligned.

Also for your setup, View > Check 'Snap to grid' and View > 'Pixel Preview'. Toggling pixel preview makes the 'snap to grid' item change to 'Snap to pixel'. If you cant find 'Snap to pixel' then try toggling 'Pixel Preview' on and off.

Slice tool caveats:
CS3 slice tool is unwieldy and annoying. It is easier to control the slice tool by first dragging near where you want the slice, then adjusting the slice using the x,y co-ordinates and the width and height (in toolbar across the top). This way you place the slice in exactly the right location to the pixel.

Knowing intimately what size your slices are will help anyway when it comes time to code the layout. I find slice stage a good time to write down the dimensions of the boxes, padding, hex values and the like on a paper printout of the layout, so all the values are right there to glance at when  you want to code it up (find glancing at paper faster than switching between windows)

Don't expect to batch slice your entire page in Illy and have it be perfect, my version definitely has a 1px shift buggy thing that crops up.

Save each slice one by one by going File > Save for web and in the web previews, zoom in to 400-800%, and check the slice boundaries are on the correct artwork boundaries.

I found the slice boundaries were sometimes shifted exactly 1px to the left when saving for web.
Not the width, just the location of the slice moves.
Don't ask why, simply go back to the artwork, and shift the x-coordinate of the slice box 1px to the right (eg add 1px to the x-co-ordinate value). Then, when you go 'Save for Web' zoom in again,  the slice will be aligned magically on the artwork boundaries.
So the x-co-ordinate of the slice is technically incorrect now, but if it slices in the location you want it to, that's all that matters.


This is the artwork and slice on the artboard, both have their left edges located at x=660px

But this is what the (bottom of the) slice looks like in Save for web preview window at 400%, it is actually slicing exactly 1px to the left of the artwork box.
So change the actual x-co-ordinate of the slice to be 661px, which, as you can see here is NOT aligned with the artworks left edge in reality...

But in the save for web preview window - it is now aligned with the artworks left edge! Go figure!

Time to buy CS5, apparently CS5 does great pixel prefect slicing and artworking.

More tips:
Set stroke alignment to be 'Inside' or 'outside' not center.

For 1px lines, make the stroke 0.999px or something, otherwise it gets blurry.

Also it is easier to align 1px rectangles to a pixel grid than 1px lines, which naturally sit on the centre of the gridline.
So try and draw filled rectangles rather than using the line tool with a stroke.

Thursday, September 2, 2010

css3 buttons

The technique described here is is my favourite its benefits are:
http://papermashup.com/pretty-css3-buttons/

Newer CSS3 browsers get rounded corners, text shadow and box shadow and gradient.

Non CSS3 capable browsers get a square coloured gradient button, which looks styled enough to suffice as a button.

I prefer not to have the gradient in CSS3 for two reasons
1/ I want non css3 browsers to get some love
2/ I want the button code to be adaptable to different coloured buttons easily, and simply use the background property for changing the button colour.

Uses a transparent .png for the gradient, which means it is adaptable for any colour button, AND can be seen in IE7, IE8, and IE6 with alpha image loader filter if you care.

see also:
http://www.zurb.com/article/266/super-awesome-buttons-with-css3-and-rgba
http://www.webdesignerwall.com/tutorials/css3-gradient-buttons/
http://somadesign.ca/2010/realistic-looking-css3-buttons/

http://www.smashingmagazine.com/2010/04/28/css3-solutions-for-internet-explorer/
http://blog.anomalyinnovations.com/2010/03/creating-a-realistic-looking-button-with-css3/

Drupal Zen theme IE fixes

IE7
When using a background image as a bullet for a custom bullet list, IE7 was showing the default bullet AND the background image. Solution:
On ul:
list-style-image:none;
list-style-position:outside;
list-style-type:none;
and on li:
list-style-image:none;/*Benefit IE7 else double bullet*/
list-style-position:outside;/*Benefit IE7 else double bullet*/
list-style-type:none;/*Benefit IE7 else double bullet*/

this made the default bullet go away.

Background image bullet 'centering' vertically, a bit off on IE when text size is set to 'larger'.
....

floated block links like for navbar etc, if they show up in IE6 as stretching to the full width.
/*Fixes from above as suggested for .primary and .secondary used here for .nicemenus*/
ul.nice-menu-down li a
{
_display: inline; /* Otherwise the blocks mistakenly get 100% width in IE5 */
_di\splay: inline-block; /* Otherwise the blocks mistakenly get 100% width in IE6 */
}

ul.nice-menu-down
{
_width: 100%; /* Otherwise IE5 treats the ul as floated */
_w\idth: auto; /* Reset to auto width for IE6 */
}


possible bugs
weird, ie6, 7, 8 all display the same...
As you can see, div.floatleft should have a bottom margin of 10px but it doesn't appear in any of the IE versions. It only happens to left-floated items, and the margin is correctly applied to right-floated items in the "clearfixed" container. There are work-arounds like using padding instead of margins but this is a bug and I was disappointed that it didn't get fixed in IE8.

this seems to be happening to me, using padding on the bottom altered layout across IEs which seemed to be ignoring the margin., except im using 1.0 strict doctype... all validates fine.
a- doctype isnt written correctly
b- IE8 is in quirks mode or emulating IE7


test with padding that will show it up. also might mean the doctype is not correctly written.



Which makes me wonder if your site isn't listed in the blacklist MSFT keeps of sites that get IE7 mode forced onto them, and hence IE8 will continue to act up like IE7 does till you manage to get out of that list.
IE8 shows that list on this pseudo URL: res://iecompat.dll/iecompatdata.xml
Or if you managed to turn on the "display all sites in compatibility mode switch".

Brings us to establishing you do to have IE8 in that dreaded compatibility mode.

Equal Height Search Forms

I have long thought it was impossible to have equal height search forms cross browser.
Equal heights for form text and from submit button are really important when the search field is embeded within a banner design with a specific position, margin etc. The header instantly looks messy if this form element isn't styled to be equal heights and pixel perfect.

The search form in Drupal is a common header element block, I'm hoping to come up with generic styling for it that is cross browser, using some nice css3 properties. Ideally, to adapt it to each site, one only needs to change the background and border colours of the form elements.

Anyway this solution looks promising:
Example text page
http://www.onderhond.com/testpages/search-form.html

Write up and code:
http://www.onderhond.com/blog/work/equal-height-search-form