Results 1 to 7 of 7

Thread: Selectors or Pseudos for individual characters?

  1. #1
    Join Date
    Jan 2006
    Location
    Ft. Smith, AR
    Posts
    795
    Thanks
    57
    Thanked 129 Times in 116 Posts

    Question Selectors or Pseudos for individual characters?

    Ok, so I've been scouring the web looking to see if this even exists (I don't think it does), and haven't found anything yet.

    I was wondering if anyone knows if there is such a thing in CSS2 that will allow you to style individual ASCII characters and/or individual plain characters (a-z 0-9)?

    I've played around with a few ideas, none of which have worked, which is making me lean more towards the idea that nothing like this exists.

    Just Ideas:
    Code:
    "{
    color:blue;
    }
    
    p:char('z'){ 
    color:blue; 
    }
    If such a thing existed it would be a great time reducer. Rather than having to use classes and spans... Just style the character itself.
    --------------------------------------------------
    Reviews, Interviews, Tutorials, and STUFF
    --------------------------------------------------
    Home of the SexyBookmarks WordPress plugin

  2. #2
    Join Date
    Mar 2007
    Location
    Currently: New York/Philadelphia
    Posts
    2,735
    Thanks
    3
    Thanked 519 Times in 507 Posts

    Default

    That would be a great time-reducer. Unfortunately, nothing like that exists. Not in CSS anyway.

    You could use JavaScript. jQuery makes this very easy. Patrick Haney at Harvard U. recently had a post about styling ampersands individually. You could use his technique with any character or characters.
    Last edited by Medyman; 09-16-2008 at 02:17 AM.

  3. The Following User Says Thank You to Medyman For This Useful Post:

    TheJoshMan (09-16-2008)

  4. #3
    Join Date
    Jan 2006
    Location
    Ft. Smith, AR
    Posts
    795
    Thanks
    57
    Thanked 129 Times in 116 Posts

    Default

    wow! that is pretty simple... Thanks.

    Let me ask you quickly, as I don't deal in a lot of "scripting"... If I were to style ampersands, or any other character which is used frequently throughout the site... Would this slow down the speed by having this script running in the background for many characters?
    --------------------------------------------------
    Reviews, Interviews, Tutorials, and STUFF
    --------------------------------------------------
    Home of the SexyBookmarks WordPress plugin

  5. #4
    Join Date
    Mar 2007
    Location
    Currently: New York/Philadelphia
    Posts
    2,735
    Thanks
    3
    Thanked 519 Times in 507 Posts

    Default

    Adding any bit of javascript will slow down your page's rendering time slightly. Something of this sort where you're manipulating the DOM will 100% have an affect. How much of one it'll have is hard to say. It really depends on what steps you've taken to optimize the code and how many characters you're manipulating.

    If you're using Firefox & Firebug (which I think you are), you should look at the YSlow plugin for tips on optimizing your code/site.
    Last edited by Medyman; 09-16-2008 at 07:56 PM.

  6. #5
    Join Date
    Jan 2006
    Location
    Ft. Smith, AR
    Posts
    795
    Thanks
    57
    Thanked 129 Times in 116 Posts

    Default

    ah, thought so... Ok, thanks for the info (and the link, I'll check that out)
    --------------------------------------------------
    Reviews, Interviews, Tutorials, and STUFF
    --------------------------------------------------
    Home of the SexyBookmarks WordPress plugin

  7. #6
    Join Date
    Mar 2007
    Location
    Currently: New York/Philadelphia
    Posts
    2,735
    Thanks
    3
    Thanked 519 Times in 507 Posts

    Default

    One small tip: Move your JS to the bottom of your page. That'll do wonders for your page rendering time, especially when running JS after the DOM has completed loading (as you would be using Patrick's technique).

  8. The Following User Says Thank You to Medyman For This Useful Post:

    TheJoshMan (09-16-2008)

  9. #7
    Join Date
    Jan 2006
    Location
    Ft. Smith, AR
    Posts
    795
    Thanks
    57
    Thanked 129 Times in 116 Posts

    Default

    ok, will do. Thank you.
    --------------------------------------------------
    Reviews, Interviews, Tutorials, and STUFF
    --------------------------------------------------
    Home of the SexyBookmarks WordPress plugin

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •