• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Is It Possible to Provide FIELDSET with Background Color?

 
Ranch Hand
Posts: 1309
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think that it would be nice to provide my FIELDSET with a background color? I do not see that attribute for the FIELDSET.

But, is it possible to do it in some way?
 
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, you can use CSS to provide nearly any element with a background color. You are using CSS for design and not attributes, correct?
 
JiaPei Jen
Ranch Hand
Posts: 1309
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please advise "how" to use CSS to provide the FIELDSET with a background color. Thank you.
 
Marc Luzietti
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Normally I would advise you to keep you CSS and HTML in separate files and link them with a line of code like the following in the HEAD of your HTML file.

<link href="PATH/YOUR.CSS" type="text/css" rel="stylesheet" media="screen"> In the css file you would write:
fieldset {
background:#3e87b7 url("/PATH/YOUR.gif") top left no-repeat;
}

You can also add style elements in the HEAD as follows.

<style type="text/css">
fieldset {
background:#3e87b7 url("/PATH/YOUR.gif") top left no-repeat;
}
</style>

That will give all FIELDSETs a background color, and an image that begins at the top left of the FIELDSET that does not repeat. If you only want one FIELDSET to have a background, you can give it an ID, <fieldset id="foo"> and instead of writing fieldset in the STYLE you would write #foo

You can also use a CLASS attribute instead or in addition to the id, i.e., <fieldset class="foo"> or <fieldset id="foo" class="foo">. You would access this in the STYLE element by writing it thus: .foo

As you can see, you can use IDs and CLASSes together in the same element. You can also use more than one class. <fieldset id="foo" class="foo foo2 foo3">

Lastly, and I don't recommend this you can put the style directly in the element itself. <fieldset style="background:#3e87b7 url("/PATH/YOUR.gif") top left no-repeat;"> This however defeats the main purpose of CSS, which is to reduce the overall amount of code.

There is a specific CSS property, background-color, which you can use, but it only handles color. Since the background property can handle color by itself, background:#3e87b7;, there isn't a lot of reason to use background-color.

Lastly, I would strongly recommend you pick up a book on CSS and learn to use it. It will make your life so much easier. No more spending all day searching through deeply nested tables trying to find the one open element that is throwing your whole design off.
[ February 12, 2007: Message edited by: Marc Luzietti ]
 
JiaPei Jen
Ranch Hand
Posts: 1309
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks very much for your time and guidance.
 
a wee bit from the empire
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic