Reputation: 37065
I need to display a company name so that the "main" part of the name appears on one line and is huge and the secondary part of the name is centered below it and smaller. Since it's not a slogan or "subtitle", I feel like it should all be in the same h1
element and, ideally, be transformed through pure CSS (meaning no spans or em
s if it can be avoided.
Example:
<h1>Big Bill's Custom Auto Parts</h1>
should appear as:
Is there a pure CSS way of doing this (even a pseudo-class not fully supported yet)?
Upvotes: 1
Views: 8107
Reputation: 1460
I tried other stuff in this thread, but this finally worked.
<h3>Tutorials <span style="font-size:14px;">(2 of them)</span></h3>
Upvotes: -1
Reputation: 4586
You said you want to do it in pure CSS way, separating content and presentation. No addtional spans
, no br
. I understand it, but if you think about your problem, you want to create presentation rule based on content. Is that making sense? Isn't that mixing content with presentation you want to avoid?
Upvotes: 1
Reputation: 36703
Is it permissible to include a new line in the heading itself? If so you can use the first-line selector like this:
HTML
<h1>Foo bar
baz</h1>
CSS
h1 {
font-size:1em;
white-space:pre;
}
h1:first-line {
font-size:3em;
}
Upvotes: 5
Reputation: 2490
If you're fine with breaking the line with a <br/>
, then you might accomplish this using the ::first-line
pseudo-element.
Upvotes: 1
Reputation: 13063
The shortest solution to this without using extra headers is the use of a span element:
<h1><span>Big Bill's</span> Custom Auto Parts</h1>
CSS:
h1.span {
/* styling rules */
}
Upvotes: 3
Reputation: 92274
Not possible, it seems to make more sense that you have two different headers and can be styled accordingly.
How would you possibly specify where changes happen without adding a <span>
within the <h1>
?
Upvotes: 6