473,399 Members | 2,146 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

making block inline collapses its width

I know I'm missing something obvious. I need a short horizontal rule
to preceed a line of text (in a bibliography in which the author is
repeated). I tried this:

<p>
<div class="rule"></div>, Title of book ...
</p>

style:

div.rule {
display: inline;
border-bottom: thin solid black;
height: 1pt; width: 8em;
}

Why does "display: inline" cause this div's width definition to be
ignored?

--

Haines Brown, KB1GRM

Apr 4 '07 #1
14 3111
Haines Brown wrote:
I know I'm missing something obvious. I need a short horizontal rule
to preceed a line of text (in a bibliography in which the author is
repeated). I tried this:

<p>
<div class="rule"></div>, Title of book ...
</p>

style:

div.rule {
display: inline;
border-bottom: thin solid black;
height: 1pt; width: 8em;
}

Try:

div.rule {
border-bottom: thin solid black;
width: 8em;
}
p.title {
position: relative;
top: -2em;
left: 8em;
}

Apr 4 '07 #2
On 4 Apr, 13:56, Haines Brown <bro...@teufel.hartford-hwp.comwrote:
I need a short horizontal rule
Then use <hrand tweak it with CSS

Don't put <divinside <peither.

Apr 4 '07 #3
On 2007-04-04, Haines Brown <br****@teufel.hartford-hwp.comwrote:
I know I'm missing something obvious. I need a short horizontal rule
to preceed a line of text (in a bibliography in which the author is
repeated). I tried this:

<p>
<div class="rule"></div>, Title of book ...
</p>

style:

div.rule {
display: inline;
border-bottom: thin solid black;
height: 1pt; width: 8em;
}

Why does "display: inline" cause this div's width definition to be
ignored?
Because the CSS spec says it should: the width property doesn't apply to
inline elements.

You could try something like this:

..rule
{
border-bottom: 1px solid black;
float: left;
clear: left;
width: 8em;
height: 1em;
}
..name
{
margin-left: 8em;
}

<div class="rule"></div><div class="name">Title of book</div>

or exactly what you had but change display: inline to display:
inline-block. Won't work on FF but will in Opera, Konqueror and in this
case, since you are setting a width directly, even perhaps IE7 from what
I hear.
Apr 4 '07 #4
Ben C <sp******@spam.eggswrites:
On 2007-04-04, Haines Brown <br****@teufel.hartford-hwp.comwrote:
Why does "display: inline" cause this div's width definition to be
ignored?

Because the CSS spec says it should: the width property doesn't apply to
inline elements.
Aha! I was thinking of the element before it was redefined. Thanks for
helping me see the light.
You could try something like this:

.rule
{
border-bottom: 1px solid black;
float: left;
clear: left;
width: 8em;
height: 1em;
}
.name
{
margin-left: 8em;
}

<div class="rule"></div><div class="name">Title of book</div>

or exactly what you had but change display: inline to display:
inline-block. Won't work on FF but will in Opera, Konqueror and in this
case, since you are setting a width directly, even perhaps IE7 from what
I hear.
The following works nicely on my FireFox 1.0.4 as well as galeon:

<p>
<div class="rule"></div>, Bibliographic title with repeated
author...
</p>

div.rule {
display: inline;
float: left;
clear: left;
position: relative; top: 1em;
margin-right: 0.2em;
border-bottom: thin solid black;
height: 1pt; width: 8em;
}

No access to IE to see if it works there. A float had occurred to me,
but not with the clear. That would seem a good solution if it stuod up
with different browsers. Thanks for helping me get this far.

--

Haines Brown, KB1GRM

Apr 4 '07 #5
On 2007-04-04, Haines Brown <br****@teufel.hartford-hwp.comwrote:
Ben C <sp******@spam.eggswrites:
>On 2007-04-04, Haines Brown <br****@teufel.hartford-hwp.comwrote:
Why does "display: inline" cause this div's width definition to be
ignored?

Because the CSS spec says it should: the width property doesn't apply to
inline elements.

Aha! I was thinking of the element before it was redefined. Thanks for
helping me see the light.
>You could try something like this:

.rule
{
border-bottom: 1px solid black;
float: left;
clear: left;
width: 8em;
height: 1em;
}
.name
{
margin-left: 8em;
}

<div class="rule"></div><div class="name">Title of book</div>

or exactly what you had but change display: inline to display:
inline-block. Won't work on FF but will in Opera, Konqueror and in this
case, since you are setting a width directly, even perhaps IE7 from what
I hear.

The following works nicely on my FireFox 1.0.4 as well as galeon:

<p>
<div class="rule"></div>, Bibliographic title with repeated
author...
</p>

div.rule {
display: inline;
float: left;
clear: left;
position: relative; top: 1em;
margin-right: 0.2em;
border-bottom: thin solid black;
height: 1pt; width: 8em;
}
Yes that looks all right, but display: inline is not necessary (floats
are automatically display: block anyway).

If you have several titles in a list you will need a separate <pfor
each one. And as someone else pointed out, you aren't supposed to put a
<divinside a <pso make the outer one a <div>.
Apr 4 '07 #6
Ben C <sp******@spam.eggswrites:
On 2007-04-04, Haines Brown <br****@teufel.hartford-hwp.comwrote:
Ben C <sp******@spam.eggswrites:
Yes that looks all right, but display: inline is not necessary (floats
are automatically display: block anyway).
Yes, that worked out nicely. Thanks. This what I now have, in case
there's any lurkers:

...
</p>
<div class="rule"></div>
<p>
, A title in a series of bibiographic references with a repeated
author...
</p>

div.rule {
float: left;
clear: left;
position: relative; top: 1em;
margin-right: 0.2em;
border-bottom: thin solid black;
height: 1pt; width: 8em;
}

I'm not clear just why a <divcan't be in a <p>, but I'll take your
word for it. I do it quite a bit. For example, in a block quote, I
want to place the author's name on next line, right justified and in a
little bit smaller type. I won't bother you with the style, but the page
markup goes like this:

<blockquote>
<p>
Text...<div class="author">Author's name</div>
</p>
</blockquote>

If I understood why it's wrong to put a <divin a <p>, I would be
motivated to redefine my style for blockquotes.

--

Haines Brown, KB1GRM
Dialectical Materialist
Apr 5 '07 #7
Haines Brown wrote:
>
<p>
Text...<div class="author">Author's name</div>
</p>

If I understood why it's wrong to put a <divin a <p>
Read the specs
http://www.w3.org/TR/html401/struct/text.html#edef-P

<!ELEMENT P - O (%inline;)*

It means <pcan only contain inline elements, which excludes <div>.
Use <spaninstead. Give it display:block if you want it to behave like
a div.

--
Berg
Apr 5 '07 #8
In article <87************@teufel.hartford-hwp.com>,
Haines Brown <br****@teufel.hartford-hwp.comwrote:
If I understood why it's wrong to put a <divin a <p>, I would be
motivated to redefine my style for blockquotes.

--

Haines Brown, KB1GRM
Dialectical Materialist
How will you understand anything like this? If you are a
dialectical materialist, you will be unable to comprehend
anything, for each raw candidate chunk that goes into such an
intellectual sausage machine must, if the machine works well and
dialectrically, come out just about the same as anything else
that goes in and out, namely a hodge podge of chaotic glug.

A paragraph basically is a series of sentences, you can see them
in all the books of the world. It is highly convenient to have an
element in html to mean this. If you stretch the meaning to
include everything under the sun, you lose the simplicity and
power of it. There are various things you can put inside the
paragraph element but a div block element is not one of them, as
this would rather open the floodgates to sausage babble.

--
dorayme
Apr 5 '07 #9
In <87************@teufel.hartford-hwp.comon Thu, 05 Apr 2007
01:50:18 GMT, Haines Brown <br****@teufel.hartford-hwp.comwrote:
>If I understood why it's wrong to put a <divin a <p>, I would be
motivated to redefine my style for blockquotes.

--

Haines Brown, KB1GRM
Dialectical Materialist

Good.

Thesis: <divinside <p>

Antithesis: increasing internal struggle by <divagainst
contradictory relationship between container and descendent

Synthesis: resolution of contradiction via reading of standards,
allowing liberation of <divleading to the establishment of the
dictatorship of the proletariat, the Peoples' Republic of Usenet
and world peace.

HTH

--
DG

mail to us****@gaelweb.co.uk goes to a black hole
news@ is valid for the time being but may not remain so
Apr 5 '07 #10
On 2007-04-05, Haines Brown <br****@teufel.hartford-hwp.comwrote:
[...]
If I understood why it's wrong to put a <divin a <p>, I would be
motivated to redefine my style for blockquotes.
The rules for HTML just say you can't, meaning that if you do there's a
risk some browsers will detect it as an error and "correct" it
unpredictably.

When it comes to CSS, a <pis just a block box with a couple of styles
(usually a top margin or something), and blocks can go inside blocks
just fine. So it shouldn't be a problem to replace <pwith <div>.

Or as someone else suggested make the contents of the <p"inline" from
an HTML point of view (i.e. <spanetc.) but turn them into CSS blocks
with display: block. Whatever seems to make more sense in a particular
case. You can map your CSS onto just about any HTML structure, so you
might as well choose a valid one.
Apr 5 '07 #11
Scripsit Haines Brown:
The following works nicely on my FireFox 1.0.4 as well as galeon:

<p>
<div class="rule"></div>, Bibliographic title with repeated
author...
</p>
It "works" only in the sense of performing (mostly by random) error
correction that happens to coincide with what you want. A <divelement
inside <pis prohibited by HTML syntax, and changing the display property
value does not affect this at all.
No access to IE to see if it works there.
It "works" in the same sense. This might be related to the beautiful weather
around here and the favorable position of Jupiter as well as the phase of
the moon.
A float had occurred to me,
but not with the clear. That would seem a good solution if it stuod up
with different browsers.
Well, yes, making the element floated lets you set its width effectively
(even on standards-conforming browsers).

But I think what you primarily need here is not CSS at all but some special
characters. Admittedly, the notations you want are comparable to list
bullets and might be logically handled using CSS, and could be handled using
generated content, but IE hasn't started supporting that yet. So in any
case, the practical solution is to insert some characters. This ensures that
the content is rendered OK even when CSS is off, though with the mild
reservation that the browser needs to support the characters you use.

It's not really rocket science characters. According to the Chicago Manual
of Style, for successive entries by the same authors, a 3-em dash followed
by a period or comma is used. Since 3-em dash does not exist as a separate
character, the practical choice is to use three em dashes:
&mdash;&mdash;&mdash;
(Support to &mdash; is almost universal in web browsers; people still using
older browsers can probably tolerate the problem caused, since they'll meet
it often anyway.)

This also gives a better rendering, since the typographic convention is to
use dashes, and they are in a considerably higher vertical position than a
bottom border is.

Now comes the CSS part. Consecutive em dashes should be joining, to give the
desired rendering. In some fonts they aren't. This is not catastrophic, but
you can check what happens with the fonts that you suggest in your CSS code,
and perhaps even use a different font for the dashes (even though this gets
clumsy, since you would need to wrap them inside some <span
class="em3">...</spanfor this). For example, in Times New Roman, Garamond,
and Arial em dashes are joining.

--
Jukka K. Korpela ("Yucca")
http://www.cs.tut.fi/~jkorpela/

Apr 5 '07 #12
Ben,

Ben C <sp******@spam.eggswrites:
The rules for HTML just say you can't, meaning that if you do
there's a risk some browsers will detect it as an error and
"correct" it unpredictably.
Thanks. That's just the explanation I needed (along with Berg's W3C
citation). I'll follow your suggestion concerning the revision of my
blockquote style.

I inadvertantly appended my full signature to a message, and that
elicited an interesting (and sad) couple of comments. In this world we
are all in trouble. I am deeply concerned about that and do what
little I can to try to change things for the better, where taking a
conventional approach obviously won't do. However, I politely truncate
my usual signature in those milieu where people are intimidated by
world views other than their own. This time I overlooked doing that,
and I apologize for stepping on people's sensitivities.

--

Haines Brown, KB1GRM

Apr 5 '07 #13
"Jukka K. Korpela" <jk******@cs.tut.fiwrites:
According to the Chicago
Manual of Style, for successive entries by the same authors, a 3-em
dash followed by a period or comma is used. Since 3-em dash does not
exist as a separate character, the practical choice is to use three em
dashes:
This also gives a better rendering, since the typographic convention
is to use dashes, and they are in a considerably higher vertical
position than a bottom border is.

Now comes the CSS part. Consecutive em dashes should be joining, to
give the desired rendering. In some fonts they aren't.
... you would need to wrap
them inside some <span class="em3">...</spanfor this). For example,
in Times New Roman, Garamond, and Arial em dashes are joining.
Thanks, Jukka. The gaps between em-dashes is what started me along the
path in the first place. I didn't realize that this gap was a function
of font. So my the whole exercise could have been avoided by doing the
simple thing of using m-dashes in combination with a font
specification.

--

Haines Brown, KB1GRM

Apr 5 '07 #14
Haines Brown wrote:
>
the whole exercise could have been avoided by doing the
simple thing of using m-dashes in combination with a font
specification.
That's what happens when you decide on a solution without really
identifying what you want to achieve. You end up fixing the wrong problem.

That's a lesson a lot of people have yet to learn. But you know better
now, eh? :)

--
Berg

Apr 5 '07 #15

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

Similar topics

3
by: Aaron | last post by:
Hi, I'm trying to use style sheets instead of tables for layout, but I'm not sure on how to do something... I have a div (100% width) containing 3 other divs. Each needs to be lined up next to...
1
by: Jens | last post by:
An image like this one <html> test1<img src="" style="width:100;height:100"/>test2 </html> is in line with the text and has a width and height. How can I get the same with a span or div...
4
by: Aaron | last post by:
I have the following divs: <div style="background-image: url(images/house_01.jpg); width: 249px; height: 346px;"></div> <div style="background-image: url(images/house_02.jpg); width: 251px;...
15
by: otto | last post by:
Any suggestions? I want a sequence of composite "blocks" (e.g. image and caption representing a product category) to wrap like text as a browser is made wider/narrower. Tables are not working well...
4
by: txican | last post by:
the HTML is: ---------------------------------------------- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> <html> <head> <title>foo</title>...
5
by: CES | last post by:
All, I was hoping that someone might be able to help me with a few questions on Aligning Block Elements properly... Basically I have a row that has a fixed width of 900px. Within the row their is...
6
by: dave8421 | last post by:
Hi, I'm a bit confused about the definition about "Prinicpal Block Boxes" in CSS 2.1 draft specification. ( http://www.w3.org/TR/2006/WD-CSS21-20061106 ) <pre> 9.2.1 Block-level elements and...
11
by: totalstranger | last post by:
I have a check box with let's say 20 elements. I would like to have it align as 4 columns, 5 rows. Without using a table and using understandable CSS is there any way to make the check boxes align...
2
dlite922
by: dlite922 | last post by:
The frustrating thing with coding with divs instead of tables is trying to get them to "act" like they're inside each other. I have a container div, and three sub-divs. First contains a plus...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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
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...

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.