inicio mail me! sindicaci;ón

t-roy.net*

blog by designer troy ginbey

Archive for September, 2008

Making the first paragraph bold with CSS

With CSS, it’s possible to make the first element after another element look different to the rest. Lets say you have a title, and two paragraphs afterwards e.g.:

<h3>My Paragraph Title</h3>
<p>This is paragraph one.</p>
<p>This is paragraph two.</p>

To make the first paragraph after the title bold, you use what’s called an ‘adjacent sibling selector‘. This allows you to target an element which follows another element. In this case, the first p element follows an h3 element. To use CSS to say that you want the first p tag after an h3 tag to be set in bold, your code would look like this:


h3 + p {font-weight: bold;}

Now each time a p tag follows an h3 tag… it is set to bold. Nice.

New CSS category

I’ve decided to add a new category to my blog - CSS. It’s been a topic I’ve wanted to write about for a while now, only if to learn a thing or two along the way. I’m going to cover all things to do with CSS - from Learning CSS, CSS techniques, Browser hacks and CSS best practices.