Please login or register.

Login with username, password and session length
Advanced search  

News:

Latest sNews - sNews 1.7 - with its own forums - for discussion and user mods.

Author Topic: How to style labels in forms?  (Read 979 times)

sNewsbn

  • Newbie
  • *
  • Karma: 0
  • Posts: 16
How to style labels in forms?
« on: November 15, 2007, 01:59:00 am »

I do not know how to pass the css to this.  :-[

$lbl = !empty($label) ? '<label for="'.$id.'">'.$label.'</label>' : '';

Please help.

Thank you
Logged

Keyrocks

  • Doug
  • ULTIMATE member
  • ******
  • Karma: 449
  • Posts: 6020
  • Semantically Challenged
    • snews.ca
Re: How to style labels in forms?
« Reply #1 on: November 15, 2007, 03:42:05 am »

That's the second variable definition string in the Form Generator function... you cannot add styling to that string.
Styling to forms must be added into the functions that generate the forms themselves. Styling for the comment form page would be added into function comment... and for the contact form page... within function contact... and so on.
Logged
Do it now... later may not come.
-------------------------------------------------------------------------------------------------
sNews 1.6 MESU | sNews 1.6 MEMU

Fred K

  • Still trying to learn stuff
  • ULTIMATE member
  • ******
  • Karma: 130
  • Posts: 2728
    • Personal
Re: How to style labels in forms?
« Reply #2 on: November 15, 2007, 05:45:23 am »

Well, in the default installation, both the contact form and comments form live in a div called "commentsbox". So, we can style the labels specifically for these forms without adding stuff to snews.php, simply by adding the following rule to our stylesheet:

Quote
.commentsbox label { styles: go here; }

Another way would be to target the id of each label, adding style rules with those id's to your stylesheet. However, that means you need to check the generated source to catch all the label id's you want to restyle. The solution above is a quicker fix, although less reliable depending on how specific your stylesheet is.

Notes:
a) Not all browsers honor author defined styles for certain elements. Label is one these elements. This means that you may be able to affect some label styles but perhaps not all.

b) If you want individual label styles for each form you'll need to change the default div class for the Contact form in snews.php, function contact(), from "commentsbox" to something else, and then add that class to your stylesheet.
« Last Edit: November 15, 2007, 05:48:47 am by Fred K (agentsmith) »
Logged