Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS setting border-top of the paragraph

  • This topic is empty.
Viewing 15 posts - 1 through 15 (of 21 total)
  • Author
    Posts
  • #37112
    prathoven
    Participant

    Hi,everyone
    I want to set the border at the top of the paragraph but instead it sets the border for every line of the paragraph.
    p.s. I only want to style achieve this effect in paragraph not by the other style
    Thanx in advance :D

    #98857
    Paulie_D
    Member
    #98866
    Senff
    Participant

    It’s possible that you have set your paragraphs to display:inline;. If you want what @Paulie_D is showing, you’ll have to make sure that the paragraph is set to display: block, which is its default type.

    #98910
    prathoven
    Participant

    @Paulie_D: Thanx for the reply paulie. I actually want it to be more flexible. Here I have tried by your code http://jsfiddle.net/prathoven/hQRc9/ .Instead I want margin only at the top of the first line(i,e margin to be actual width of the first line not the whole paragraph) not over the box. :D….

    @Senff
    : Thanx for the nice comment :)

    #98922
    Senff
    Participant

    That’s a different thing you want than what you initially said then.

    If you want to have the line at the top of the paragraph, use @Paulie_D ‘s example.
    If you want to have the line at the top of the first line of the paragraph only, you’ll have to wrap it in a div or span and apply the line to that.

    #98926
    Paulie_D
    Member

    I’m thinking there might be something you could do with

    p:first-line

    but I can’t get it to work.

    #98929
    Senff
    Participant

    Indeed you can’t use a border on the first-line pseudo-element. You CAN, however, apply a background image to it, so if you have an image of a line, maybe you want to use that (and set it to repeat-x, obviously). Something like this: http://jsfiddle.net/senff/Wd8ck/

    (for some reason it doesn’t always show right away — sometimes I have to switch to another tab and then switch back….hmm!)

    #98932
    prathoven
    Participant

    @paulie_D & Senff: I guess it can’t be achieved by fair codes….Thanx for your effort..really appreciate it!

    #98942
    Paulie_D
    Member

    I’d want it to just ‘Work’ on a paragraph…I don’t want to have to add paragraphs, spans or whatever.

    I thought about a background gradient but I couldn’t get that to work either.

    As far as I can see the BG image option would be the only solution..which I did get to work but seemed a lot of hassle for a minor design element.

    #98943
    Brightonmike
    Member

    Paulie, you must always have “content:”” for psuedo elements.

    http://jsfiddle.net/brightonmike/Wd8ck/1/

    #98945
    Paulie_D
    Member

    @Brightonmike Actually, not in this case…

    I think you need it for ‘before’ and ‘after’ but not in this instance.

    http://jsfiddle.net/Paulie_D/j7Ua8/1/

    #98976

    @Brightonmike You are spot on, pseudo-elements must have the content property declared. However, :first-line is a pseudo-class, and they do not use the content property. /cc @Paulie_D

    #98980
    Senff
    Participant

    Not sure if that’s true @joshuanhibbert! Since we’re targeting the first line IN a P-element, I believe that makes it a pseudo element.

    A pseudo class would target the P-element itself (like P:first-child).

    I may be wrong here, but that’s how I always understood it.

    #98985

    @Senff Yeah, you are right. I am now stumped as to what I was thinking when I wrote the above comment. These things happen, thanks for the clarification!

    #98988
    Senff
    Participant

    Ha! Man, you confused me there and made me seriously doubt myself! ;)

    (still confused about that thing about the need for “content:” though….)

Viewing 15 posts - 1 through 15 (of 21 total)
  • The forum ‘CSS’ is closed to new topics and replies.