CSS Hacks and IE7

This is a really great article on how to hack IE7. CSS Hacks and IE7

  • The Child Selector
  • This selector uses a “>” symbol as a “combinator” that is placed between two parts of a CSS selector, and indicates that the target of the rule is the element on the right side of the “>” combinator, but only when that element is a direct child of the element to the left of the combinator. Thus, the selector table>td can never target any element, because TD’s are never direct children of tables, only of TR’s. On the other hand, the selector tr>td would select every TD on the page, since all TD’s are direct children of TR’s.

    The main difference between the Child combinator and the familiar space combinator is that the space combinator is a “descendant” combinator, meaning that the element to the right of the space only needs to be between the tags of the element on the left to be selected. So with the selector table td, all TD’s will selected, since TD’s always fall between the tag pair of one table or another.

    The Child combinator is quite useful for targeting rules to direct children of an element, without also targeting the more deeply nested descendants as well. Unfortunately, up until IE7 there was no point in using it for its intended purpose, since so few of the viewing public would get the benefits of the styling.

  • The Adjacent Sibling Selector
    • This selector is a “+” combinator symbol placed between parts of a selector, and is very similar to the Child combinator. The only difference between the two is that while the Child combinator points to direct children of an element, the Adjacent Sibling combinator points to an element which directly follows another element in the source.

      Thus the selector tr+td cannot select anything, because no TD ever directly follows a TR. Instead, TD’s are contained inside TR’s, and that is not considered to be “following” the TR. However, the selector tr+tr would select any TR that directly followed another TR, which means that every TR within a table would be selected except for the very first TR in that table.

      Get it? An adjacent sibling element not only follows its previous sibling, but is also completely separate from it. Further, if two DIV’s are in sequence and each contains a paragraph, those two paragraphs are not considered siblings, because they reside in different parent elements. The fact that one follows another means nothing unless the following sibling starts at the same point where the previous sibling ends.

  • Star HTML

Oh, you want to know about that structural thing? Well, the hack that uses it is called the star-html hack, and it works by taking advantage of an oddity in Explorer’s treatment of the Document Object Model, or DOM for short. Simply stated, all web pages start with a root element called html, which then contains two children, the head and the body elements. Those two then contain other children, and so forth.

  • Most browsers obey this arrangement, but Explorer for both Win and Mac do not. They seem to think there is a mysterious element enclosing the html element! It’s pretty strange, but in fact this extra outer “root” element has no apparent ill effects on web pages, and remained unnoticed for years, until Edwardson Tan began experimenting with CSS selectors. He found that a selector written as * html  .targetelement would apply the styles to .targetelement, but only for the IE browsers.

    Think about it. That star is the “universal” selector, so it points to any element, but it comes before html. Therefore, the full selector in effect says: “Select .targetelement when it is contained within html, and when html is contained within any other element”.

ALA’s New Print Styles + hasLayout

Perplexing little CSS issue that’s dogged me for ages: Why does MSIE have weird positioning some times? It could be because of hasLayout, and all you need to do, is apply position:relative to the CSS declaration:

A List Apart: Articles: ALA’s New Print Styles

The only little oddity here is position: relative. I included that because IE/Win has a tendency to make elements disappear if you pull them upward like this. The cure is to position them, which I suspect triggers the hasLayout flag. I don’t pretend to understand all the nuances of hasLayout, but recent information from Microsoft and third-party sources has shed quite a bit of light on the subject–it would appear that many of the layout problems that bedevil us in IE/Win are the result of an element not having hasLayout.

Authenticate Apache 2 using Mac OS X Open Directory

macosxhints.com – Authenticate Apache 2 using Mac OS X Open Directory

Change this:

cn=user1,dn=example,dn=com

to this:

uid=user1,dn=example,dn=com

so it looks like this:

AuthType Basic
AuthName "Testing of LDAP auth"
AuthBasicProvider ldap
AuthzLDAPAuthoritative on
AuthLDAPBindDN uid=testaccount1,cn=users,dc=geo,dc=vuw,dc=ac,dc=nz
AuthLDAPBindPassword [plaintext password for user 'testaccount1']
AuthLDAPURL ldap://server1.geo.vuw.ac.nz/dc=geo,dc=vuw,dc=ac,dc=nz
require valid-user

Clear as mud? 😉

WordPressMU Bug Trac for fixing target=”_blank”

W3C - World Wide Web ConsortiumOnce upon a time, we had a vexing problem where we couldn’t set the @target (OT: @target is tech-speak/jargon/euphemism for ‘target attribute’). Actually, you could set it, but when you ‘saved’ the post or story, TinyMCE (that nifty toolbar interface for formatting blog posts used by WordPress and a million other places). Here’s where I figured out what was wrong. I don’t know why they ‘broke’ the @target attribute, although I do know that the ‘target’ attribute was deprecated in HTML 4.01, as well as XHTML 1.0. However, there are ways around it, like via JavaScript and XHTML modules which are pretty darn cool.

Anyway, when we upgrade WordPressMU to the next version, we’ll likely need to ‘fix’ this again, so here’s $98 bucks worth of direction:

Changeset 1022 – WordPress MU Trac – Trac

Just change this:

$allowedposttags = array(
‘address’ => array(),
‘a’ => array(
‘href’ => array(), ‘title’ => array(),
‘rel’ => array(), ‘rev’ => array(),
‘name’ => array()
),

to this:

$allowedposttags = array(
‘address’ => array(),
‘a’ => array(
‘href’ => array(), ‘title’ => array(),
‘rel’ => array(), ‘rev’ => array(),
‘name’ => array(), ‘target’ => array()
),

NOTE: This change was downgraded to determine if it inexplicably affects bandwidth performance.

WordPressMU Bug Trac for fixing target=”_blank”

W3C - World Wide Web ConsortiumOnce upon a time, we had a vexing problem where we couldn’t set the @target (OT: @target is tech-speak/jargon/euphemism for ‘target attribute’). Actually, you could set it, but when you ‘saved’ the post or story, TinyMCE (that nifty toolbar interface for formatting blog posts used by WordPress and a million other places). Here’s where I figured out what was wrong. I don’t know why they ‘broke’ the @target attribute, although I do know that the ‘target’ attribute was deprecated in HTML 4.01, as well as XHTML 1.0. However, there are ways around it, like via JavaScript and XHTML modules which are pretty darn cool.

Anyway, when we upgrade WordPressMU to the next version, we’ll likely need to ‘fix’ this again, so here’s $98 bucks worth of direction:

Changeset 1022 – WordPress MU Trac – Trac

Just change this:

$allowedposttags = array(
‘address’ => array(),
‘a’ => array(
‘href’ => array(), ‘title’ => array(),
‘rel’ => array(), ‘rev’ => array(),
‘name’ => array()
),

to this:

$allowedposttags = array(
‘address’ => array(),
‘a’ => array(
‘href’ => array(), ‘title’ => array(),
‘rel’ => array(), ‘rev’ => array(),
‘name’ => array(), ‘target’ => array()
),

NOTE: This change was downgraded to determine if it inexplicably affects bandwidth performance.