Counter/content not working for h2


#1

Hello, I am currently having two issues in newer version of Pressbooks.

My counter isn’t working for the h2 nor will any content appear before the h2. The CSS I used is below:

.chapter {
counter-reset: zeroh2;}

chapter h2::before {
content: counter(chaptnum) “.” counter(zeroh2);
counter-increment: zeroh2;}

** I also tried just using h2::before with no results.

I know the counter-reset works as it is tied to multiple counters. I tried using the code below to see if anything will appear but nothing shows.

.chapter h2::before {
content: “Apple”;}

Can someone help to figure what is wrong? I looked through the default CSS to ensure I am not overlapping with anything also.

Thank you.


#2

Hi, can you clarify what your expected result is? I’m trying to understand from your example code but I can’t quite figure out what you are looking for. Are you trying to automatically number <h2> elements within chapters?


#3

Hello Ned,

I actually found a solution around this issues. I changed all the headers down a level since the counters worked for them.

I was trying to automatically number the <h2> elements within the chapters but nothing would appear. I applied a class also to ensure it only targeted the chapter <h2> but this did not work also.


#4

Glad you were able to sort this out!