473,405 Members | 2,444 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,405 software developers and data experts.

Using <fieldset><legend> in a <div>

goatboy
So I am hosting a site from my home server, and I would like the main page to be an area for updates about the site. I am providing these updates in a blog-style format, using this code:

Expand|Select|Wrap|Line Numbers
  1. <form><fieldset>
  2. <legend>December 15, 2009</legend>
  3.  
  4. <p>This is an update.  Lorem ipsum, etc. etc. and so on.</p>
  5.  
  6. --goatboy
  7.  
  8. </fieldset></form>
  9.  
Now, while this layout looks exactly like what I want, it does not make sense to format it within a set of <form> tags. Is there a way to achieve the same style - a line around the content with the legend text interrupting the line - without using the <form> tag? Ideally, I'd like to just use <div> and <legend>, but something tells me that is not possible.

I'm entirely open to CSS, but I'd prefer staying away from images, javascript, and PHP. It's not that I don't like them or understand them, I just think it's easier to stick with what I have.

ADD: I have searched this forum and Google, but I'm not entirely sure what it's called, so my searches haven't turned up anything relevant.

Thanks in advance,
goatboy
Dec 16 '09 #1

✓ answered by drhowarddrfine

Here's one example of what you can do with a div. Replacing the div with a p has the same effect:
Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
  2. <html>
  3. <head>
  4. <title></title>
  5. <style type="text/css">
  6. div{border:1px solid;padding:10px}
  7. span{display:inline:block;position:relative;top:-20px;background-color:#fff;}
  8. </style>
  9. <body>
  10.  
  11.         <div><span>Some stuff.</span>More stuff</div>
  12.  
  13. </body>
  14. </html>
  15.  
  16.  

6 19238
Dormilich
8,658 Expert Mod 8TB
Ideally, I'd like to just use <div> and <legend>, but something tells me that is not possible.
that one is called DTD. <legend> must only be used as child element of <fieldset>, which itself is only allowed inside <form>.

I’d propose a div with a border and a label bearing the text. use position: relative and a negative top value to shift the text onto the border.
Dec 16 '09 #2
drhowarddrfine
7,435 Expert 4TB
Here's one example of what you can do with a div. Replacing the div with a p has the same effect:
Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
  2. <html>
  3. <head>
  4. <title></title>
  5. <style type="text/css">
  6. div{border:1px solid;padding:10px}
  7. span{display:inline:block;position:relative;top:-20px;background-color:#fff;}
  8. </style>
  9. <body>
  10.  
  11.         <div><span>Some stuff.</span>More stuff</div>
  12.  
  13. </body>
  14. </html>
  15.  
  16.  
Dec 16 '09 #3
Dormilich
8,658 Expert Mod 8TB
Expand|Select|Wrap|Line Numbers
  1. display:inline:block;
do you mean
Expand|Select|Wrap|Line Numbers
  1. display:inline-block;
?
Dec 16 '09 #4
I'm sure that's what he meant, but changing it made no difference (at least in Firefox). Either way, that's exactly what I was looking for! Thank you!
Dec 16 '09 #5
Dormilich
8,658 Expert Mod 8TB
I think it doesn’t matter, if the display is inline or inline-block.
Dec 16 '09 #6
drhowarddrfine
7,435 Expert 4TB
Yeah, the inline-block thing wasn't necessary.
Dec 16 '09 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

14
by: Ian Rastall | last post by:
I'm curious as to the group's feelings about using the <fieldset> and <legend> tags around elements other than <form> elements ... I wrote a small test file:...
9
by: Warren Post | last post by:
At <http://snow.prohosting.com/srcopan/src/search.html> I have a simple form, using the following code provided by my site search provider: <form method="get"...
4
by: _Raven | last post by:
Okay, I am playing with submitting forms with Ajax. I am trying to adapt this script to my forms: http://www.captain.at/howto-ajax-form-post-get.php I have included my code at the bottom of this...
0
by: bobmct | last post by:
Gentlemen; I'm in the process of migrating several pages from HTML under frames to noframes using css using the three or four box design. For most of my efforts its going well. However, one...
5
nathj
by: nathj | last post by:
Hi All, I'm working on a new site that has a two column layout underneath a title bar. If you check out: http://www.christianleadership.org.uk/scratch/mainpage.php using IE or Opera you will...
17
by: malathib | last post by:
Hi, I have used a rich text editor in my application. I got it from one of the site.all are JS files. My problem is, i want to call a javascript function from the iframe. Can anybody help...
5
matheussousuke
by: matheussousuke | last post by:
Hello, I'm using tiny MCE plugin on my oscommerce and it is inserting my website URL when I use insert image function in the emails. The goal is: Make it send the email with the URL...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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,...
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.