W3C home > Mailing lists > Public > w3c-wai-ig@w3.org > April to June 2005

Re: Inline Style Sheet Question

From: David Woolley <david@djwhome.demon.co.uk>
Date: Thu, 7 Apr 2005 23:05:54 +0100 (BST)
Message-Id: <200504072205.j37M5sG03675@djwhome.demon.co.uk>
To: w3c-wai-ig@w3.org

> Sorry this may be my lack of knowledge on style sheets, but what if
> there is one word in the paragraph that needs to have a different style?

That depends on why it needs to have a different style.  In most cases
you will make it into an appropriate inline element, e.g. strong, em, 
cite, etc.  If there really is no standard element, first consider whether
the styling is gratuitous, and if not use a span element.

> But by default the <p> tag creates a break after the closing </p>. So if

A p element contains a paragraph, it should not be used purely for its
styling effects.

P {
      Color: red;
P EM {
      Font-weight: bold;

<p>here is my <em>paragraph</em>.</p>

> I understand that I could use a <span> tag around the word 'paragraph'.

You can't use a tag around anything, but you can use an element.

> But how would I use the style sheet if it is an abuse of style sheets to
> create my own class (ex. .red)?

The abuses are in:

- using span when there is a more specific inline element;

- naming classes after the intended presentation, rather than what that
  presentation signifies.

If you replaced red by danger, you might have a valid use of span, but
you would first have to be sure that it would not be better to use
<strong class="danger">.....</strong>, or similarly with em.
Received on Thursday, 7 April 2005 22:05:58 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 20:36:25 UTC