Monday, June 30, 2008

Using the ~ selector in CSS

So Eric Wendelin is wondering what can be done with the CSS3 indirectly-adjacent sibling selector, now that the majority of browsers actually support it. Here are some ideas off the top of my head:

Minimalist horizontal menus

<style type="text/css">
ul {list-style:none;margin:0;padding:0;}
li {float:left;}
li ~ li {border-left:1px solid #000;}
</style>
<ul>
  <li><a href="#">Home</a></li>
  <li><a href="#">About</a></li>
  <li><a href="#">Contact</a></li>
</ul>

The code above puts borders in all menu items, except the first. Like so:

This same idea can be applied for other menu layouts (it's particularly useful for boxy, multi-level left menu designs.)

Equally spaced 3-column layout

.column {background:#eee;float:left;width:32%;}
.column ~ .column {margin-left:2%;}
html:
<div class="column">Text</div>
<div class="column">Text</div>
<div class="column">Text</div>

Pretty self-explanatory, I hope :)

Sematic Inference

Say you have a blog:
<style type="text/css">
h1 ~ p {/*article styles*/}
h2 ~ p {/*comment styles*/}
</style>
<h1>Using the ~ selector in CSS</h1>
<p>Bla bla bla, Leo talks too much.</p>
<h2>Comments</h2>
<p>First.</p>
<p>lolol photoshopped</p>

Much cleaner than wrapping divs everywhere, huh?

Anything else?

I'm sure there are plenty of other cooler ways to use this selector. Now that Microsoft has announced that it will no longer sell XP, IE6 will become less and less of a concern and I expect web developers to start exploring new CSS techniques more.

If you got more ideas, post them up :)

OFF - The Internet really can be your hard drive

Interesting.

Regexp and javascript

Jeff Atwood psoted some nice insights on regular expressions. It sorta made me realize that the Javascript's built-in regexp class sucks ass :)

A lesson on humility

Sigh. Conservapedia folks, let me put this nicely: no one cares what your opinion is.

Friday, June 27, 2008

Not so private

I saw quite a few people surprised at this little known tidbit about eval in firefox. Maybe it's just me, but can't we simply download the script and run it in Rhino or whatever if we really wanted to extract "private" data for an attack?

I thought one of the golden rules of security is that there's no such thing as client-side security.

Making sites faster the easy way

Awesome presentation by YSlow lead dev Stoyan Stefanov.

Wednesday, June 25, 2008

flXHR - Flash based Ajax

Very nice library, it claims to have good interoperability with js libraries, cross-domain communication capabilities and a few interesting and advanced goodies.

I'd like to see if this technology can be explored more in the realm of Comet.

Formy - CSS Framework for forms

It's still beta and doesn't have a demo up, but it might be nice to look at it.

Tuesday, June 24, 2008

Blogging and content stealing

Interesting point. Imho, there's something terribly wrong when people want to essentially capitalize on their opinion's copyright - especially when they can use the legal system to do so.

Monday, June 23, 2008

RDFa and microformats

Interesting reads if you're interested in semantic web and are guilty of using HTML attributes intended for human consumption for machine data.