homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / CSS
Forum Library, Charter, Moderators: not2easy

CSS Forum

Child for the heading

WebmasterWorld Senior Member 5+ Year Member

Msg#: 4661810 posted 1:59 pm on Apr 9, 2014 (gmt 0)

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">



Msg#: 4661810 posted 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.


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

Msg#: 4661810 posted 9:01 pm on Apr 9, 2014 (gmt 0)

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.

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / CSS
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved