On Mon, Jul 11, 2011 at 2:35 AM, Geoff Lane <[email protected]> wrote: > On Sunday, July 10, 2011, 5:04:32 PM, a list member wrote in a private > message: > >> vertical-align is a property that only applies to a table cell. If >> you use it, you should have it in the style attribute of the <td>. > > FWIW, that's what I thought until I read the W3Schools page at > http://www.w3schools.com/cssref/pr_pos_vertical-align.asp, in which > they give an explicit example of using it with an image. At the time I > had an issue where the middle of the div aligned vertically with the > bottom of the images. So I applied 'vertical-align:middle' to both > images and divs and obtained the correct vertical alignment! So, > contrary to what I'd previously believed and what the respondent seems > to believe, you can apply vertical-align to inline elements to align > them with some datum of the containing element.
Looking at the spec (http://www.w3.org/TR/CSS21/visudet.html#propdef-vertical-align), it does say that the property applies to "inline-level and table-cell" elements. Reading that made me look to see if there is a display value that is specifically "inline-level", but I didn't find it, so I guess it applies to "inline", "inline-block", or "inline-table" (ref: http://www.w3.org/TR/CSS21/visuren.html#propdef-display) I have tried to use "vertical-align: middle" on elements other than table cells before, but I never had any luck getting it to work. I haven't even had a great deal of luck using it along with elements where I've set "display: table-cell", but that's probably user error on my part. It never occurred to me that it could be applied to an element to allow it to vertically align to the middle of it's parent element. So, I've learned something new. >> Why use display: inline-block at all? Try floating them to the left >> inside the cell. > > That's something I hadn't tried but will keep in mind in case I need > it for the future. The issue was solved by using spans in place of > divs as 'pseudo-icons'. I've now deployed the application and don't > want to go through the change procedure so soon and so I'll leave it > be for now. > >> /* Of course, it's always a good idea to separate your CSS from your HTML */ > > Of course it is *provided that you can actually do that*. As I > explained in my OP, the generated code is to be inserted into someone > else's web page. For further info, I don't have access to the head > section and so can neither link style sheets nor create a style block > and thus have no choice but explicitly style every element for which > styling is required. Sorry if that wasn't made clear in my OP. Sorry... I didn't read the OP carefully enough. -- Ghodmode http://www.ghodmode.com/blog ______________________________________________________________________ css-discuss [[email protected]] http://www.css-discuss.org/mailman/listinfo/css-d List wiki/FAQ -- http://css-discuss.incutio.com/ List policies -- http://css-discuss.org/policies.html Supported by evolt.org -- http://www.evolt.org/help_support_evolt/
