Previous Message
Next Message

Re: [css-d] first-line applied to only first element

Sent by Mark Newhouse on 28 January 2002 12:12

on 1/27/02 11:43 AM, Porter Glendinning at [EMAIL-REMOVED] wrote:

>> how can i get the first <p> in the <div> (which has an id) to accept
>> a first-line property *without* it cascading to all other <p>s in the
>> <div>?
> I believe something like this is the selector syntax you're looking
> for:
> div#id > p:first-child::first-line
> Don't be surprised, however, if browser support is, shall we say,
> "interesting."

How about:

    #id {
        width: 50%;
        margin-left: 25%;
        font-family: verdana;
        border: 1px solid gray;
        padding: 10px;
    #id p:first-line {
        font-weight: bold;
        font-family: georgia;

    #id p+p:first-line {
        font-weight: normal;
        font-family: verdana;

Worked on all Standards Compliant browsers I have on my Mac (IE5, Moz9.7,

I used the adjacent sibling combinator to accomplish this. Note that if any
other tag (IMG, Hx, etc.) comes between your P tags, then the p:first-line
styling will take over for that paragraph...


--Mark Newhouse
  We put the "blah" in blog...
Previous Message
Next Message

Message thread: