Programming

The Thing About Good Questions

I just spent the better part of an hour trying to write a good question.

I’ve not yet posted a question on Stack Overflow (SO), though I’ve used it many, many times to help me when I get stuck coding something. Tonight I finally found something that Google and SO couldn’t give me the answer to. So, I decided I’d write a question and see what happens.

Well, I got my answer. But not from the community. I was reminded that two-thirds of solving a problem is asking the right question. Spending an hour writing it (what? I’m paranoid about my writing when it’s not an explicit request for help, it had to be perfect ‘nammit) meant I had to carefully analyse many parts of the problem and find clearer ways to word it. As I did this, being a paranoid nut job, I also double-checked that no assertions of fact that I was making were wrong. During one of the fact checks, I noticed that an example of a line of CSS in my project was done slightly differently in another persons. Voila, there’s my answer.

Ask and ye shall receive. Not because someone will give it to you, but because if you ask properly you’ll probably find the answer out for yourself.

For those who are curious, there are some more details below the fold.

So, it turns out that

[css]
ol {
counter-reset: alpha;
counter-reset: beta;
}[/css]

will not work. This is what I’d initially written (in amongst about 20 lines of other stuff that was correct.
You can, however achieve exactly the same thing by using:
[css]
ol {
counter-reset: alpha beta;
}[/css]

So. Yeah. Spending a couple of hours on that seems rather… wasteful… when I break it down to something that simple.
For the really curious, what I was trying to do was get an ordered list that has two different types of list entry with separate counters, but not nested. For an example of it in action, see this page.

And here’s an example of the code:

The HTML:

[html]
<ol class="session-notes">
<li class="session">Example session 1</li>
<li class="aside">Example aside 1</li>
<li class="session">Example session 2</li>
<li class="session">Example session 3</li>
<li class="aside">Example aside 2</li>
<ol>
[/html]

The CSS:

[css]
ol.session-notes {
counter-reset: session aside;
list-style-type: none;
}

ol.session-notes li.session:before{
content: ‘Session ‘ counter(session, decimal) ‘: ‘;
counter-increment: session;
}

ol.session-notes li.aside:before {
content: ‘Aside ‘ counter(aside, decimal) ‘: ‘;
counter-increment: aside;
}[/css]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s