Results 1 to 4 of 4

Thread: How to center the legend element in a fieldset

  1. #1
    Join Date
    Nov 2007
    Location
    USA
    Posts
    170
    Thanks
    8
    Thanked 22 Times in 22 Posts

    Default How to center the legend element in a fieldset

    Is it possible to get the legend text in a <fieldset> to be in the center rather than on the left? Thanks
    What is obvious to you might not be to another.


    My Site

  2. #2
    Join Date
    Oct 2008
    Location
    Sweden
    Posts
    2,023
    Thanks
    17
    Thanked 319 Times in 318 Posts
    Blog Entries
    3

    Default

    Unfortunately the <legend> tag can be quite difficult to control. This might be because <fieldset> and <legend> are non-presentational tags (although they might appear presentational).

    After a lot of firebugging, the only solution I could find is not only deprecated, but also invalid (yaiks)! What I would recommend is to leave it the way it is, but I'll show you my highly unsemantic solution anyways:
    HTML Code:
    <legend align="center">Tables for layout, yaay!</legend>
    I'm sure that wouldn't even validate in the 90's but it's the only one that does the job. The choice is yours.

    Good luck!

  3. #3
    Join Date
    Mar 2007
    Location
    Currently: New York/Philadelphia
    Posts
    2,735
    Thanks
    3
    Thanked 519 Times in 507 Posts

    Default

    Quote Originally Posted by Snookerman View Post
    I'm sure that wouldn't even validate in the 90's but it's the only one that does the job. The choice is yours.
    Who cares? It does the job so he should use it. Validation isn't everything. It's one thing if using align="center" on the <legend> tag would break something. But it won't. Validation shouldn't be the ultimate goal - usability and accessibility should. If centering the legend makes the page more user-friendly, then go for it.

    In fact, if you're using the legend tag for it's original intent, it's the more semantic approach. I think you're confusing semantics and validation in your statement above.

  4. #4
    Join Date
    Oct 2008
    Location
    Sweden
    Posts
    2,023
    Thanks
    17
    Thanked 319 Times in 318 Posts
    Blog Entries
    3

    Default

    Quote Originally Posted by Medyman View Post
    Who cares? It does the job so he should use it. Validation isn't everything. It's one thing if using align="center" on the <legend> tag would break something. But it won't. Validation shouldn't be the ultimate goal - usability and accessibility should. If centering the legend makes the page more user-friendly, then go for it.
    I agree, but try telling that to some of my clients..

    Quote Originally Posted by Medyman View Post
    In fact, if you're using the legend tag for it's original intent, it's the more semantic approach. I think you're confusing semantics and validation in your statement above.
    I didn't say it's unsemantic because it doesn't validate, I was just thinking there might be problems with screen readers (which I don't know anything about). Then again, I do tend to refer to semantics when I talk about the overall professionalism of a site so you're right.

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •