Posts Tagged CSS
CSS in PHP
Posted by admin in Web design & development on February 2, 2011
The last time I tried to render CSS through PHP was many, many moons ago. I didn’t work and I couldn’t figure it out. Yesterday I tried again and found out why… the MIME type must be set as text/css. D’oh. Set MIME type like this:
< ?php
header("Content-Type: text/css");
?>
Weird line-height in Chrome?
Posted by admin in Asides, Web design & development on January 28, 2011
Specifying line-height on an <a> in a <li> will not work in your webkit based browsers. Line-height needs to be set on the containing <li> to work at all in Chrome or consistently in Firefox. Now you know.
The CSS reset has been reset
Posted by admin in Web design & development on January 9, 2011
The grandaddy of all CSS resets hits version 2.o beta: Eric Meyer’s Reset Revisited. See also the subsequent thoughts on how to handle :focus.
Update! Now at Beta 2.
On CSS image replacement techniques and SEO
Posted by admin in Web design & development on October 16, 2010
Having learnt that properly structuring headings is very important to SEO but wishing to be able to style and design pages beyond the limitations of HTML text I’ve often reverted to this old CSS hack to replace heading text with nice image substitutes:
.hide {visibility: hidden; display: block; line-height: 0; font-size: 0.1em; height: 0; margin: 0; padding: 0;}
I’ve been wondering about whether this is still good practice recently and found today that I’m not the only one… thanks to Laura Carlson’s [webdev] Web Design Update newsletter (subscribe already! HERE) I seem to have found a reasonable debate in this post and subsequent comments from Roger Johansson on his site at 456 Berea Street. In short:
- Avoid using CSS techniques to hide text from your site. Especially avoid hiding text that contains keywords that are important to your site.
- If you want to provide an accessible format of text that is in an image – use a regular image with alt text in preference to any CSS background image replacing actual text. CSS sprites may be very useful to reduce server requests and page load times but use sprites for pure graphic elements only – not text.
In a moment of clarity I realise that an image is valid within a heading tag… but whether alt text within an image within a heading tag is as strong for SEO as regular text in that same heading tag (whether or not hidden/positioned off-screen) is a question that could do with a clear answer. I suspect that alt text is not as strong: clear guidelines from those Google folks (I do love you) seem to be lacking again. SEO and graphically rich websites are not something that the engines of Google can cope with properly when faced with trying to be a sh*t umbrella (in gmail or the wider web) against the legions of spam pedlars out there who would love to stuff keywords into every corner of a page. In the meantime the life of a web designer remains tough.
Poor me.
JavaScript Rounded Corners
Posted by admin in Web design & development on November 27, 2009
Rounded corners with CSS and graphics is OK – but a pain to set up – requiring custom images and plenty of extra markup. JavaScript – particularly when helped by jQuery comes to the rescue and makes it fairly trivial. Requiremtents: must work with IE6, IE7, iE8, FF and Safari (note about IE8 below).
Main contenders:
- for jQuery: jquery.corner.js from rc.rctonline.nl
- for jQuery: jquery.corner.js from malsup.com
- for jQuery: cornerz
- stand alone: curvycorners
Using #1 at the moment. Would like to try them all again in the light of the IE8 workaround below. Gotta say I now think #3 (cornerz) looks most promising in terms of size and ability. Going to have another look to see which ones look to CSS first (for those browsers that are modern – and not Internet Explorer) before turning to JavaScript.
Problem with most of these is IE8 doesn’t play nice… fix seems simply to add the behave like IE7 meta tag: <tt><meta http-equiv=”X-UA-Compatible” content=”IE=EmulateIE7″ /></tt>
First impressions:
- good, non-transparent outside corner
- good,
- throws errors in IE7, non-transparent outside corner
- slow in IE,
Keeping your sites optimised
Posted by admin in Web design & development on June 11, 2009
The sites I’ve been working on had been suffering from flab. A JavaScript library here (jQuery of course), a plug-in there, another, another, another… then a large plug-in that loads it’s own plug-ins (Shadowbox v3 – I’m talking to you).
It took a kick from outside (“your site x sucks HTTP requests and bandwidth”) to realise things were going downhill.
So – with the help of the good folk at Yahoo YSlow and the new copy-cat-kid on the block (Google Page Speed) with their plug-ins for a plug-in(firebug) for Firefox [oh the irony]… I’ve started to get things in line again.
Both YSlow and Page Speed have helpful links and information once called – and now I can pat myself on the back for having improved my YSlow scores from an ‘F’ to a ‘B’. Wetware heh.
Main issues I was able were too fix were too many HTTP requests and a lack of explicit caching direction from the web server. Nextly I’ll be looking at getting interface elements into a sprites for future jobs. (Must take this sprite/CSS creation tool for a spin. Looks absolutely fab.)
Reduce HTTP requests
While combining CSS files is trivial, combining a bunch of disparate JS files into one is not painless – I’ve had to drop a jQuery tooltip plug-in as it wouldn’t play nice when bundled up with its playground compatriots.
Server side caching and compression
is achieved the following htaccess rules:
##Cacheing static components FileETag none Header unset Etag # Far future 1 YEAR <FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|swf|mp3|mp4|css|js)$"> Header set Expires "Thu, 15 Apr 2010 20:00:00 GMT" </FilesMatch> <FilesMatch "scripts.inc.php$"> Header set Expires "Thu, 15 Apr 2010 20:00:00 GMT" </FilesMatch> # Past last modified <FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|swf|mp3|mp4|css|js)$"> Header set last-modified "Sun, 13 Jul 2008 20:00:00 GMT" </FilesMatch> <FilesMatch "scripts.inc.php$"> Header set last-modified "Sun, 13 Jul 2008 20:00:00 GMT" </FilesMatch> #Compress <IfModule mod_deflate.c> <FilesMatch "\.(js|css)$"> SetOutputFilter DEFLATE </FilesMatch> </IfModule>
Shadowbox woes
I now may be on the lookout for a replacement to Shadowbox. Shadowbow v2 was great – it came with lots of build options and could be explicitly launched by jQuery on Document Ready. v2 wasn’t IE8 compatible however – forcing an upgrade to v3 – still in beta… Ho hum. This required an updated version of the JW FLV media player which I’m not mad keen on – and that needs a new licence. While Shadowbox is now very clever and can automatically find it’s own dependencies – it has many of these – each one with an HTTP request. While it is easy to combine the whole bundle into a single file its something I’d rather not have to do/keep track of – I’ve already got a rod for my back with the other jQuery plugins…
Free from the shackles of CSS conditional comments
Posted by admin in Web design & development on September 8, 2009
CSS hacks are here to stay but lets bundle them up in a single style-sheet…
After trying to “hide my shame” [was it Zeldman that turned me on to CondComs with this phrase?] by using conditional comments for IE specific hacks, I’m now happier with the new and revised and reverted wisdom that throwing all your CSS code into a single style sheet is best.
I’d read Meiert’s «CondComs are bad» article ages ago but I was still a print designer by trade so the message went into a back drawer in my mind. It’s a good read on the cons and it’s updated too.
For a while I have found elegance in removing offending and non-valid CSS code to fix bug for IE, particularly as a way of dealing with proprietary MS code when incorporating PNGs with full alpha transparency into IE6. I’ve since moved away from trying to make png24 work with IE6; and then came the speed demons and calls from the gallery for fewer HTTP requests.
Avoid Extra Stylesheets
Hide my shame.
The only reason I was still using conditional comments was because I had failed to find an IE-7-only selector hack. Thanks to Web Devout. Look there for the comprehensive list – for posterity I copy paste here:
CSS hacks in CSS Selectors
conditional comments, CSS, hacks, IE, ie7
No Comments