Welcome to WebmasterWorld Guest from

Forum Moderators: not2easy

Message Too Old, No Replies

Child for the heading



1:59 pm on Apr 9, 2014 (gmt 0)

WebmasterWorld Senior Member 5+ Year Member

I have sections like:
<dd class="benefits1">

<h2>Title1, child1</h2>

<dd class="benefits1">

<h2>Title1, child1</h2>


As I have more columns I like to set margin left just for column one. Is this technical possible with code like:
.benefits1 h2 {
text-indent: 20px;
.benefits1 h2:first-child {
text-indent: 0;

Notice the first column which should have 0 on the left hand side. As i understand <dd class="benefits1"> is not only one. There are many and it will not be defined as text-indent: 0; inside the first dd like <dd class="benefits1">


2:17 pm on Apr 9, 2014 (gmt 0)

Are you expecting the h2 element in the second dd to have a text indent of 20px? It will not since the h2 element is considered the first child contained within the dd element.


9:01 pm on Apr 9, 2014 (gmt 0)

WebmasterWorld Senior Member lucy24 is a WebmasterWorld Top Contributor of All Time Top Contributors Of The Month

Your post says "margin" but the CSS says "text-indent". They're different things. And here it's possible you want neither of the two, but instead "padding".

.benefits1 h2:first-child

"Apply these rules if and only if an h2 is the first child of a .benefits". From your prose I would have thought you wanted
dl dd.benefits1:first-child

instead. It's hard to understand without seeing the site; in particular, where do the columns fit in? It doesn't sound as if you're using a multi-column layout, since that would be handled with column-spacing instead.

Featured Threads

Hot Threads This Week

Hot Threads This Month