Web Design Web Design Forum
Registration is free! Here you can view your subscribed threads, work with private messages and edit your profile and preferences Calendar Find other members Frequently Asked Questions Search
Home Web Design

Convenient web based access to our favorite web design Usenet groups

web design reviews

This is Interesting: Free Magazines for Graphics designers and webmasters  





  Last Thread  Next Thread
Author
Thread Post New Thread   

Selector for text or <p> after <H2>?
 

John Rowe




quote this post edit post

IP Loged report this post

Old Post  01-22-05 - 12:21 AM  
I run the web site for a University department. A few of
my authors will carefully write:

<h3>Title</h3>
<p>Some text here.</p>
<p>Second paragraph.</p>

Most of us can't be bothered(!):

<h3>Title</h3>
Some text here.
<p>Second paragraph.

I would like my margin under the <h3> to be a little less than my
margin between paragraphs. My problem is that I can't seem to come up
with a selector that distinguishes between the two cases above, ie <h3>
immediately followed by <p> and <h3> followed by text then <p>.

A selector like: h3 + p matches both. Is there a selector for 'naked'
text?

Thanks

John




Post Follow-Up to this message ]
Re: Selector for text or <p> after <H2>?
 

Philip Herlihy




quote this post edit post

IP Loged report this post

Old Post  01-22-05 - 12:21 AM  
Will this not be matched by rules for "body"?

--
####################
##  PH, London
####################
"John Rowe" <rowe@excc.ex.ac.uk> wrote in message
news:vnbrbiwkze.fsf@kenny.ex.ac.uk...
>I run the web site for a University department. A few of
> my authors will carefully write:
>
> <h3>Title</h3>
> <p>Some text here.</p>
> <p>Second paragraph.</p>
>
> Most of us can't be bothered(!):
>
> <h3>Title</h3>
> Some text here.
> <p>Second paragraph.
>
> I would like my margin under the <h3> to be a little less than my
> margin between paragraphs. My problem is that I can't seem to come up
> with a selector that distinguishes between the two cases above, ie <h3>
> immediately followed by <p> and <h3> followed by text then <p>.
>
> A selector like: h3 + p matches both. Is there a selector for 'naked'
> text?
>
> Thanks
>
> John
>
>




Post Follow-Up to this message ]
Re: Selector for text or <p> after <H2>?
 

Jukka K. Korpela




quote this post edit post

IP Loged report this post

Old Post  01-22-05 - 05:15 PM  
John Rowe <rowe@excc.ex.ac.uk> wrote:

> I run the web site for a University department. A few of
> my authors will carefully write:
>
> <h3>Title</h3>
> <p>Some text here.</p>
> <p>Second paragraph.</p>

That's fine (if it's really a 3rd level heading, i.e. a heading for a
subsection of the page), though it's generally a good idea to use id
attributes for all headings (e.g. <h3 id="foo">Title</h3> ). Such attributes
mainly let anyone link to a specific section or subsection, but they can
also be used to style an individual element. There's less temptation to use
a style="..." attribute when you already have an id attribute by which you
can refer to the element simply in CSS (using #foo).

> Most of us can't be bothered(!):
>
> <h3>Title</h3>
> Some text here.
> <p>Second paragraph.

And shouldn't. Loose text isn't good practice. Never was. "Some text here."
is clearly meant to be a paragraph and should be marked up as one. The idea
of <p> as a _separator_ is very obsolete (though it was part of the
original, pre-HTML 2.0 design of HTML). Moreover, it makes it impossible to
style the paragraph since it's not an element and you cannot refer to it in
CSS in any way.

> I would like my margin under the <h3> to be a little less than my
> margin between paragraphs.

Fine. So that's the real problem. One solution:
- use logical markup (the first method you described, with all paragraphs
marked up as paragraphs)
- set margin-top for p to 0 and margin-bottom to the desired value
(say 1em)
- set margin-top and margin-bottom for headings so that margin-top is
fairly large (1.5em might be OK) and margin-bottom is essentially
smaller (like 0.5em).
That way, the vertical space between h3 and p only depends on the
margin-bottom value you have set for h3. Paragraphs will be separated from
each other due to the margin-bottom setting.

This approach has some impact on what you might wish to do e.g. for
a (data) table followed by a paragraph. Since the paragraph now has no top
margin, you would need to set margin-bottom for table to avoid putting the
table and the paragraph too close. But it's usually a good idea to set
some vertical margins for a (data) table anyway.

> My problem is that I can't seem to come up
> with a selector that distinguishes between the two cases above, ie <h3>
> immediately followed by <p> and <h3> followed by text then <p>.

No, what you describe as a problem is just a dead-end attempt at a
solution. Luckily you described the real problem too!

> A selector like: h3 + p matches both.

Yes, but that's not practically very relevant, since IE doesn't support
such selectors at all.

> Is there a selector for 'naked' text?

No, and that's one reason why we should not use any naked text.

--
Yucca, http://www.cs.tut.fi/~jkorpela/


Post Follow-Up to this message ]
Sponsored Links
 





All times are GMT. The time now is 10:14 AM. Post New Thread   
  Previous Last Thread   Next Thread next
Stylesheets archive | Show Printable Version | Email this Page | Subscribe to this Thread

Popular forums

Adobe Photoshop forum Macromedia Flash Web Site Design
Dreamweaver FrontPage forum
JavaScript Forum XML forum
Style Sheets VRML
Forum Jump:
Rate This Thread:

 

XML RSS Feed web design latest articles Syndicate our forum via XML or simple JavaScript

Web Design archive  Database administration help  


Top Home  -  Register  -  Control Panel   -  Memberlist  -  Calendar  -  Faq  -  Search Top