treehouse : what would you like to learn today?
Web Design Web Development iOS Development

Auto style for first sentence of post

  • I know there's CSS for the first letter of a post (magazine style, etc.), but wasn't there also a way to make (for example) the first sentence bold, or a different colour?

    I'm going to Google it myself, I'd just said I'd post it here should anyone else have the same idea... If I find anything I'll post.
  • Heh - first result on Google brought up another forum where the response to a user was:

    You have two choices; you can either add an element around the first sentance using either Javascript or a server side language when used in conjunction with regex. Then the element that's been created can by styled with CSS.


    Fair enough. If I don't want to use spans I have to use Javascript. Any idea's there?



    @admin - move to Javascript forum if you want.
  • You can do the first letter or the first line, but yeah, actually finding the full stop (period) where the first sentence ends is beyond the scope of css. http://www.w3schools.com/CSS/CSS_pseudo_elements.asp