Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9180533
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T18:04:50+00:00 2026-06-17T18:04:50+00:00

My goal is to render fieldsets with a border and the legend to be

  • 0

My goal is to render fieldsets with a border and the legend to be located at the top with a background color. The background color of the legend should extend to the full width of the fieldset.

Based on Make a legend fill up the full width within the fieldset, I started with the following jsfiddle: http://jsfiddle.net/pdgreen/wcYXX/0.

It looks good, but fieldset has no padding, so the form elements are too close to the borders. When I add in the padding, I am left with: http://jsfiddle.net/pdgreen/wcYXX/1/.

The content looks fine, but the title not longer extends the the width of the fieldset.

If I surround the content with a div, I can add in the padding: http://jsfiddle.net/pdgreen/wcYXX/2/, however that requires the additional div.

Is there a way to make it look like the third fiddle, without the extra div?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T18:04:51+00:00Added an answer on June 17, 2026 at 6:04 pm

    Yes, by counteracting the padding of the fieldset with negative margin on the legend. Something like this: http://jsfiddle.net/wcYXX/3/

    I set the margin of the fieldset to -5px (the same as the padding of the fieldset, but negative) and then added 5px padding to put the text back where it belongs.

    This also means you no longer need the border-box, which is not well supported in legacy browsers.

    The fieldset css now looks like this:

    fieldset legend {
        background: #369;
        color: #FFF;
        font-weight: 700;
        text-align: left;
        white-space:nowrap;
    
        margin: -5px;
        padding: 5px;
        display: block;
        width: 100%;
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

GOAL : To customize the background view of cell. Here is what I am
Goal: to create a percentage column based off the values of calculated columns. Here's
Goal: To render a google map using geolocation. I am trying to implement the
Goal I have a top-level Collection named Players and a Session variable called 'n'.
I have an index.php page which includes a navBar.inc page to render the top
How I can render template without extend? i have simple renderer and i want
<form id=login_frm method=post action = /login/user_auth/> <fieldset> <legend>Login:</legend> <label for=id_email>Email</label> <input type=text name=email id=id_email
I render an alert bar as a partial at the top of the screen
Given any arbitrary, one-line string, my goal is to render it into a bitmap
Goal : I wants when I drag image it become fade so we can

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.