user4313162
user4313162

Reputation:

How can I text-indent the start of a every paragraph apart from the first in css?

As the title says I have a p element and I want to text-indent the start of every paragraph apart the the first paragraph where I don't want any text-indent. How can I do this in css?

Upvotes: 0

Views: 527

Answers (6)

Bharat Sewani
Bharat Sewani

Reputation: 668

you can use this:

p:not(:first-child) {
   text-indent:30px;
}

Upvotes: 0

Karuppiah RK
Karuppiah RK

Reputation: 3964

CSS

p > span {
  margin: 5px;
  display: inline-block;
}
p > span:first-child {
  text-indent: 25px;
}

JSFIDDLE

Upvotes: 0

David Taiaroa
David Taiaroa

Reputation: 25475

Another option which wouldn't require adding any additional markup or classes to your page: http://codepen.io/panchroma/pen/jyaOJL

p{
  text-indent:20px;
}

body p:first-child{
  text-indent:0;
}

Good luck!

Upvotes: 0

Bhushan wagh
Bhushan wagh

Reputation: 197

DEMO

    p{
  text-indent:40px
}
p:first-child{
  text-indent:0;
}

Upvotes: 0

Tanasos
Tanasos

Reputation: 4098

You can do this simply by applying a text-indent property to your paragraphs as so:

p {
    text-indent: 50px;
}

The text-indent property specifies how much horizontal space text should be moved before the beginning of the first line of the text content of an element. Spacing is calculated from the starting edge of the block-level container element.

Excerpt from CSS Tricks.

Upvotes: 0

Aakash Thakur
Aakash Thakur

Reputation: 3895

You can give your first paragraph a class and then can do the following:

p:not(.first){
  text-indent:30px
}

Please refer to this link:https://jsfiddle.net/n5pjgev6/400/

Upvotes: 2

Related Questions