Forum Moderators: not2easy

Message Too Old, No Replies

Subclass?

Can I put in subclasses?

         

Adam5000

7:59 pm on Nov 3, 2008 (gmt 0)

10+ Year Member



Here's the situation. I'm styling several pages with an external style sheet. And I've got several kinds of paragraphs. I've got a basic paragraph with a first line indent of 5%.

<style type="text/css">

p
{
text-indent: 5%;
}

</style>

Then I've got some headers of different sizes with no indent.

<style type="text/css">

p.header_20
{
text-indent: 0%;
text-size: 20pt;
}

p.header_14
{
text-indent: 0%;
text-size: 14pt;
}

</style>

What I'd like to do is have something like

<style type="text/css">

p
{
text-indent: 5%
}

p.header
{
text-indent: 0%;
}

p.header.20
{
text-size: 20pt;
}

p.header.14
{
text-size: 14pt;
}

</style>

Or in other words, a way to say all basic paragraphs indented 5%, all header paragraphs indented 0%, and the header 20 paragraph text-size: 20pt and the header 14 paragraph text-size: 14pt.

What I'm trying to do is eliminate the text-indent: 0% redundancy in the header tags. But I don't think <p class="header.14" will work. Is there a way to specificy a sub class for the different header tags?

Help!

swa66

9:52 pm on Nov 3, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I think what you seek is the ability to have multiple classes on one element. Something that's quite possible:


p {
text-indent: 5%
}
p.header {
text-indent: 0%;
}
p.large {
text-size: 20pt;
}
p.small {
text-size: 14pt;
}


<p class="header small"> ...</p>

Alternatively you can also apply something to more than one class:


p {
text-indent: 5%
}
p.smallheader, p.largeheader {
text-indent: 0%;
}
p.largeheader {
text-size: 20pt;
}
p.smallheader {
text-size: 14pt;
}

But the bigger question might be if you should do this. Why not use (and style <h1>...<h6> headers. It's their function to be a header ...

Adam5000

10:55 pm on Nov 3, 2008 (gmt 0)

10+ Year Member



That did the job. Multiple classes in one tag. You're fantastic.