473,480 Members | 1,918 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Faking up a run-in header


Posting here always feels a bit like poking one's head into
the mouth of a lion, but here goes:

I have someone who wants some headings (h3) to run-in to the
following paragraph. Obviously, the "correct" thing to do is
to use display: run-in for the h3s and say that it'll work
in opera and konqueror, be readable in the other browsers
and look right when the implementations catch up (nine years
since the omission was reported for mozilla, I believe, so
there's an implication of non-breath-holding in this).

The other thing to do is to add some non-semantic mark-up
and fake the effect that way. I've made a couple of
attempts; neither is entirely satisfactory:

http://www.cl.cam.ac.uk/~jf15/StyleT...ke-run-in.html

(which begins with real run-in h3s) The first method I tried
is to style the h3 and following paragraph as inline. This
sort of works with problems mentioned at the url above, the
most irritating of which is the requirement for something to
prevent running in if the text under the header is only one
paragraph (using an empty paragraph works in everything I've
tried except IE7, which doesn't seem to collapse it).

The second is to use floats, but I can't see how to get the
baselines to line up correctly.

Have I missed something obvious? Is there a better way of
preventing run-in with the first method? Is there a better
method all together?

--
Jón Fairbairn Jo***********@cl.cam.ac.uk
Apr 18 '07 #1
5 2492
Jón Fairbairn wrote:
>
The second is to use floats, but I can't see how to get the
baselines to line up correctly.
Try offsetting the header with some negative margins and/or relative
positioning. How much depends on the font-size, but if you set values in
ems, it should adapt reasonably well.

--
Berg
Apr 18 '07 #2
Bergamot <be******@visi.comwrites:
Jón Fairbairn wrote:

The second is to use floats, but I can't see how to get the
baselines to line up correctly.

Try offsetting the header with some negative margins and/or relative
positioning. How much depends on the font-size, but if you set values in
ems, it should adapt reasonably well.
Thanks, but. I've already tried the first and thought about
the second, but what I'm missing is how to work out where
the baseline will be in the floated block, and hence by how
much to offset it. With the current (zero) margins, Firefox
and Opera display the floated text too low, but Konqueror
and IE6 put it in the right place. I don't know which of
them is doing the right thing...

--
Jón Fairbairn Jo***********@cl.cam.ac.uk

Apr 18 '07 #3
On 2007-04-18, Jón Fairbairn <jo***********@cl.cam.ac.ukwrote:
Bergamot <be******@visi.comwrites:
>Jón Fairbairn wrote:
>
The second is to use floats, but I can't see how to get the
baselines to line up correctly.

Try offsetting the header with some negative margins and/or relative
positioning. How much depends on the font-size, but if you set values in
ems, it should adapt reasonably well.

Thanks, but. I've already tried the first and thought about
the second, but what I'm missing is how to work out where
the baseline will be in the floated block, and hence by how
much to offset it. With the current (zero) margins, Firefox
and Opera display the floated text too low, but Konqueror
and IE6 put it in the right place. I don't know which of
them is doing the right thing...
The baseline of the text in the float should be lower than that of the
adjoining text if the font size for h3 is larger, which it usually is.

Second-guessing the offset from the top of a linebox to the baseline is
not feasible I don't think. It depends on the font, its various metrics
and on how the browser interprets them. You don't get fine-grained
control over that stuff with CSS.

display: inline is really the only way to do this (and use a span for
the first-letter etc. the way you are).
Apr 18 '07 #4
Ben C <sp******@spam.eggswrites:
On 2007-04-18, Jón Fairbairn <jo***********@cl.cam.ac.ukwrote:
Bergamot <be******@visi.comwrites:
Jón Fairbairn wrote:

The second is to use floats, but I can't see how to get the
baselines to line up correctly.

The baseline of the text in the float should be lower than that of the
adjoining text if the font size for h3 is larger, which it usually is.
I believe that I set the font-size to be the same as the
paragraph text. It's possible that font-weight might make a
difference, though it doesn't seem to. In fact, what seems
to happen (in firefox) is that the position of the float
beats with the pixel alignment at a slightly different rate
from the lines in the paragraphs, so some of the floated
headings line up and some are 1px lower. Strange.
Second-guessing the offset from the top of a linebox to the baseline is
not feasible I don't think. It depends on the font, its various metrics
and on how the browser interprets them. You don't get fine-grained
control over that stuff with CSS.
Seems like a bit of a deficiency to me, though I don't mean
control of font and metrics); the baseline of a line of text
is a fundamental typographic property, yet block boxes don't
have them.
display: inline is really the only way to do this (and use a span for
the first-letter etc. the way you are).
What would be the correct way of introducing the break? I
don't think I fully understand the way margins are supposed
to collapse (and possibly, neither does IE7), so while most
browsers produce a reasonable spacing when an empty
paragraph is used, IE7 introduces extra space. (I think
that's what happens; I don't normally have windows running)

* * *

One last bit of unpleasantness: neither using display:
inline no floats produces the correct effect if display:
run-in is also set. With the inline version, the markup for
the following paragraph messes it up, and with float, the
float seems to take precedence (in Opera at least), though
I'm not sure it should.

Thanks for your help,

--
Jón Fairbairn Jo***********@cl.cam.ac.uk
Apr 20 '07 #5
On 2007-04-20, Jón Fairbairn <jo***********@cl.cam.ac.ukwrote:
Ben C <sp******@spam.eggswrites:
>On 2007-04-18, J?n Fairbairn <jo***********@cl.cam.ac.ukwrote:
Bergamot <be******@visi.comwrites:

J?n Fairbairn wrote:

The second is to use floats, but I can't see how to get the
baselines to line up correctly.

The baseline of the text in the float should be lower than that of the
adjoining text if the font size for h3 is larger, which it usually is.

I believe that I set the font-size to be the same as the
paragraph text.
Ah, I missed that detail.
It's possible that font-weight might make a
difference, though it doesn't seem to. In fact, what seems
to happen (in firefox) is that the position of the float
beats with the pixel alignment at a slightly different rate
from the lines in the paragraphs, so some of the floated
headings line up and some are 1px lower. Strange.
That is a bit strange.
>Second-guessing the offset from the top of a linebox to the baseline is
not feasible I don't think. It depends on the font, its various metrics
and on how the browser interprets them. You don't get fine-grained
control over that stuff with CSS.

Seems like a bit of a deficiency to me, though I don't mean
control of font and metrics); the baseline of a line of text
is a fundamental typographic property, yet block boxes don't
have them.
The baseline of a block box would presumably be the baseline of the
first linebox in it (which might be nested in several more block boxes).
That's how the baseline for a table cell is determined.

It's not clear how you'd use the baseline on a block box, but it makes
sense on a table cell or inline-block because they can line up with
other things to their left and right.

In Opera you vertical-align: baseline on an inline-block works (and
could be used for your headings). Konqueror on the other hand considers
inline blocks not to have a baseline and so aligns the inline-block's
bottom margin edge with the parent baseline instead. FF doesn't support
inline-blocks at all.

It comes down to whether an inline-block is "inline-level" or not. I
think it is, and therefore that Opera is right.
>display: inline is really the only way to do this (and use a span for
the first-letter etc. the way you are).

What would be the correct way of introducing the break? I
don't think I fully understand the way margins are supposed
to collapse (and possibly, neither does IE7), so while most
browsers produce a reasonable spacing when an empty
paragraph is used, IE7 introduces extra space.
The top and bottom margins of an empty <pshould collapse with each
other: they count as "adjoining" since there is nothing in between. So

div { margin: 20px 0; }

<div>Hello</div>
<div></div>
<div>world</div>

should display just the same as

<div>Hello</div>
<div>world</div>

I use <divin this example rather than <pbecause <pintroduces an
extra confusion here. The HTML 4.0 spec says:

"We discourage authors from using empty P elements. User agents
should ignore empty P elements."

even though <p></pis technically valid [assuming (%inline;)* means "0
or more inlines" which I should think it does].

It doesn't normally make a difference, but if I write:

<p>Hello</p>
<p style="margin: 600px 0"></p>
<p>world</p>

Should I get a 600px gap between the first and third paragraphs or not?
Not if I ignore empty P elements.
(I think that's what happens; I don't normally have windows running)
I don't know what IE does either.
* * *

One last bit of unpleasantness: neither using display:
inline no floats produces the correct effect if display:
run-in is also set. With the inline version, the markup for
the following paragraph messes it up, and with float, the
float seems to take precedence (in Opera at least), though
I'm not sure it should.
It should. If you set float to anything other than "none" you get
display: block regardless of what you set for display. This is in
section 9.7 of the CSS 2.1 spec.
Apr 20 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
4934
by: Dica | last post by:
i'm just learning java now, so this might be obvious, but not to me. my app needs to do two things: (1) connect to and fetch a list of tasks for a user from a web service (2) connect to mapquest...
5
2737
by: Ed Leafe | last post by:
I'm working on creating a generic runtime engine for the Dabo framework. Right now I'm focusing on Windows, since many of our potential users are running on that platform. I've got py2exe and Inno...
2
9356
by: Zeno Lee | last post by:
I'm using File.Exists to test a file on my C: drive. My program was strongly named and had caspol -af run on it to allow it to run from the network. There are 3 ways I am doing this: 1) Run...
2
2480
by: duncan | last post by:
why does this work :- <HEAD> ...... <SCRIPT LANGUAGE="javascript"> function test() { alert("test 1") } </SCRIPT>
8
10147
by: Antony | last post by:
compiler£ºVisual Studio.Net 2003 (VC7.1) compile type£ºDebug problem: wanted more information about the "Run-Time Check Failure #n",thanks! Example1: #include "stdafx.h" void malice() {...
4
4400
by: J. Frank Parnell | last post by:
Hi there, I have a list of links which point to e.g. thescript.php?album=somePictures1 thescript.php?album=somePictures2 This list is about 3000 links. Each album may have 500 or more...
1
1518
by: GaryDean | last post by:
We have a new server2003 machine that was built like all the rest - IIS and everything needed to run asp.net apps. We have a test asp.net website that we use for new machines to make sure...
2
1406
pentahari
by: pentahari | last post by:
i create the exe using visual basic 6.0. how can i run the exe using run command with out full path of the exe. For ex: open the notepad using run command. (start-->run-->notepad) open the...
16
5970
by: maya | last post by:
hi, this is very annoying.. this is on IE7/Vista.. whenever I load a pg with JavaScript on it IE refuses to run the JavaScript (I'm talking about JavaScript written BY ME....;) and the weird...
1
4843
by: leimeisei | last post by:
So, I've got an application that Ive found that will only run under certain versions of Windows. Is there any way for me to lie to it when it checks the OS version so that it thinks its Vista...
0
6904
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7032
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6730
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5321
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4767
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
2990
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
2976
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1294
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
174
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.