473,756 Members | 1,823 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Title followed by a horizontal rule on the same line

What I'm trying to achieve is to have a title followed by a horizontal
rule on the same line. For example:

Living on Mars ----------------
Living on Mars would be at best
impractical for the following
reasons: blah blah blah

Living on Earth ---------------
Life has evolved on earth for
the following reasons: blah blah
blah

I'm guessing the mark up I should be using would be as follows (please
advise if rubbish)

<div class="section" >
<div class="title">L iving on Mars<hr/></div>
<div class="body">Li ve has evolved on Mars....</div>
</div>

(for example I'm not sure whether I should be using <span/> instead of
<div/> here).

And...I'm clueless about how to write the CSS to control the <hr/>
within the <div class="title"/>. Also, is it possible to have the
<hr/> inserted by the style-sheet (i.e. not included in the mark up at
all)?

This would have to work with IE6 as well as Firefox...

All help would be much appreciated!

Thanks

Griff

Jul 21 '05 #1
2 4238
Griff:
Living on Mars ----------------
Living on Mars would be at best

<div class="section" >
<div class="title">L iving on Mars<hr/></div>
<div class="body">Li ve has evolved on Mars....</div>
</div>
The heading element types ('h1' through 'h6') are there for a reason and
I don't beleive you need to embed the paragraph(s) ('p') of text in yet
another 'div'.

<div class="section" >
<h2>Living on Mars</h2>
<p>Living on Mars would be at best...</p>
</div>

.section {border-top: thin solid;}
h2 {position: relative; top: -0.5em; margin: 0;
background-color: white; width: 25%;}

You'll probably have to adjust margins and paddings. If you don't want
to use a "fixed" width like that "25%", you'd have to let the 'h2' box
automatically shrink to fit its content. There a several ways to achieve
that (with 'float' or 'display'), none of which works in all browsers
(the same).

<evil>Or you strongly abuse HTML by using 'fieldset' and 'legend'.</>
(for example I'm not sure whether I should be using <span/> instead of
<div/> here).


Hey, you already know *both* element types of HTML! (Well, and 'hr'.)
Jul 21 '05 #2
In our last episode,
<11************ *********@g43g2 000cwa.googlegr oups.com>,
the lovely and talented Griff
broadcast on comp.infosystem s.www.authoring.stylesheets:
What I'm trying to achieve is to have a title followed by a horizontal
rule on the same line. For example: Living on Mars ----------------
Living on Mars would be at best
impractical for the following
reasons: blah blah blah Living on Earth ---------------
Life has evolved on earth for
the following reasons: blah blah
blah I'm guessing the mark up I should be using would be as follows (please
advise if rubbish) <div class="section" >
<div class="title">L iving on Mars<hr/></div>
<div class="body">Li ve has evolved on Mars....</div>
</div> (for example I'm not sure whether I should be using <span/> instead of
<div/> here). And...I'm clueless about how to write the CSS to control the <hr/>
within the <div class="title"/>. Also, is it possible to have the
<hr/> inserted by the style-sheet (i.e. not included in the mark up at
all)? This would have to work with IE6 as well as Firefox... All help would be much appreciated!
One suggestion might be:

<div>
<h6 class="alpha">L iving on Mars</h6><hr class="beta" />
</div>
<p>Life has evolved on Mars &hellip;</p>

with styles

..alpha {display: inline; }
..beta {display: inline; width: 10em; }

or something of the sort, with the heading level and width
adjusted appropriately.

This doesn't work in Firefox and doesn't work in Opera, so I
guess it probably won't work in IE. (You get a vertical hairline
in both cases.)
This would have to work with IE6 as well as Firefox...


Let's think about this. The essence of what HR is supposed to
mean is a separator. It doesn't make any sense to separate the
header from its text. So it is hard to fault browsers which
don't understand inlining HR. But maybe they do understand: a
vertical hairline *is* an inline separator, so the browser
people have a pretty good rationale for this rendering -- if
they did it on purpose.

What you want is strictly a visual effect which really doesn't
have any meaning.

So how about

<h6>Life on Mars <img src="myrule.gif " alt=""></h6>

With the empty alt, that should do it -- as much as it can be
done. The alt is empty because your rule is purely decorative
and has no meaning. You could make alt="-------" for a similar
appearance in text browsers, but you probably don't really want
speech browsers trying to render "-------".
--
Lars Eighner ei*****@io.com http://www.larseighner.com/
"Fascism should more properly be called corporatism, since it is the
merger of state and corporate power."-Benito Mussolini * When you write the
check to pay your taxes, remember there are two l's in "Halliburto n."
Jul 21 '05 #3

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

Similar topics

6
21233
by: Francesco Moi | last post by:
Hello I want to insert an horizontal rule into my HTML page, but without using <HR> or <HR size=1>, as I consider it oldfashioned. Does anybody know a good way? Thank you very much.
1
2707
by: Aamir | last post by:
I need to minimize the line gap horizontal rule <hr> causes with the top and bottom text. I want them all squeeze together. Can it be done ? thanks IA Aamir
3
12445
by: Christian Zenner | last post by:
Hi, how can I make a horizontal rule (<hr>) 1px thin? Border: 1px; doesn't work. Anybody has an idea? Thanks, Chris
3
6375
by: Bernd Kuegle | last post by:
Hi! How is it possible to reduce the space between a pargraph and a horizontal line (top and bottom). It doesn´t look so good if there is the default space. Thanks Bernd
10
2957
by: lothar | last post by:
for the horizontal rule element, the w3c HTML 4.01 specification http://www.w3.org/TR/html4/cover.html states that the align, noshade, size and width attributes are deprecated. it gives an example using the deprecated attributes, but no indication as to how to avoid the deprecated attributes. what CSS properties can be used to replace the hr tag noshade and size
6
13025
by: shapper | last post by:
Hello, I have 20 inputs in a web page and I would like to add a 200px gray horizontal line as a separator every 5 inputs to divide the form into sections. What is the best way to do this? Do I need to place each group of 5 inputs inside a div and define the div bottom border to 1px?
2
1782
by: laredotornado | last post by:
Hi, Maybe I should break down and use tables, but I wanted to query the experts first. Below, I would like the words "First name" and "Last Name" to appear on the same horizontal and I would like the text fields to appear on the same horizontal. But I would like the words to appear above the text fields. The below creates four different lines: <div>
3
1707
by: phpmel | last post by:
Hi Guys, Can a horizontal rule be visible and not visible within the <td> tag of a row on a table? <tr> <td colspan="4" style="height: 20px; text-align: left" valign="middle"> <hr id ="hr" style="width: 75%" visible="false" > </td> </tr>
3
8270
by: phpmel | last post by:
Hi Guys, Can a horizontal rule be visible and not visible within the <td> tag of a row on a table? <tr> <td colspan="4" style="height: 20px; text-align: left" valign="middle"> <hr id ="hr" style="width: 75%" visible="false" > </td> </tr>
0
9275
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10034
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9872
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9843
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9713
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6534
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5142
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3358
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2666
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.