/    Sign up×
Community /Pin to ProfileBookmark

:last-child and lists, taming, content

Hello, all. I’m trying to do a test on taming lists with CSS, and I’ve run into a snag. I’m trying to get the word “and” to appear before the final list item by using [font=courier]ul.tame > li:last-child:before {content: ” and “;}[/font] This should hypothetically work; this example was modified from the [url=http://www.w3.org/TR/2001/CR-css3-selectors-20011113/#last-child-pseudo]list of CSS3 selectors[/url], but it doesn’t, nor does :last-child work at all in any of my experiments. I thought it was supported by Firefox 0.9, but maybe I’m wrong or I just had a syntax error. Thanks in advance.

The list is just a normal list of links, with the class name “tame”, with a paragraph (class=”ul-int”; <ul> intro) before it. The CSS is as follows:

[code] ul.tame, p.ul-int {margin: 0; list-style: none; display: inline; padding: 0; }
ul.tame li {display: inline;}
ul.tame li:after {content: “, “;}
[b]ul.tame > li:last-child:before {content: ” and”;}
ul.tame > li:last-child:after {content: “.”;}[/b][/code]

to post a comment
CSS

2 Comments(s)

Copy linkTweet thisAlerts:
@FangJun 26.2004 — Works for me with Moz.1.6, FF0.9. Opera ok except for " and " and IE just does the inline.
Copy linkTweet thisAlerts:
@Ben_RogersauthorJun 26.2004 — *Feels stupid* When you said that, I started up a whole new page to test it out, and I know why it wasn't working. All my previous tests were styling a generated list= and the </ul> tag was never generated. Oops. I guess this is what happens when you're tired... it's 5am and I'm still not tired.. bleh.

Well, thanks, Fang. Now, I have to test some of those other pseudo classes- they might be useful, especially if I decide to give my xBlogLite an actual comments style. The last-child pseudo not working was making me think none of the obscure ones did.
×

Success!

Help @Ben_Rogers spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...