473,888 Members | 1,453 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Label Styling

Hello,

I am styling the labels on a section of my page as follows:

label {float: left; width: 6.5em;}

Now I want to remove this styling from a label that has the class
"Message".

Mu questions are:
Is the default value for floating of the label Left?
And should I define the width to 100%?

Thanks,
Miguel
Jun 27 '08 #1
2 2462
Scripsit shapper:
I am styling the labels on a section of my page as follows:

label {float: left; width: 6.5em;}
Presumably to make labels equally wide. An alternative, and in some ways
better, approach is to use a table of labels and input fields.
Now I want to remove this styling from a label that has the class
"Message".
I wonder why. Is it really a _label_, and why would you make its
rendering different from other labels.
Is the default value for floating of the label Left?
No, the initial value is float: none, and that's what browsers use as
the default.
And should I define the width to 100%?
No, the initial value is width: auto, and that's what browsers use as
the default. For an inline element (which is what label elements are by
default), the the default means that the element is as wide as needed
for its content.

--
Jukka K. Korpela ("Yucca")
http://www.cs.tut.fi/~jkorpela/

Jun 27 '08 #2
On Jun 16, 12:07 pm, "Jukka K. Korpela" <jkorp...@cs.tu t.fiwrote:
Scripsit shapper:
I am styling the labels on a section of my page as follows:
label {float: left; width: 6.5em;}

Presumably to make labels equally wide. An alternative, and in some ways
better, approach is to use a table of labels and input fields.
Now I want to remove this styling from a label that has the class
"Message".

I wonder why. Is it really a _label_, and why would you make its
rendering different from other labels.
Is the default value for floating of the label Left?

No, the initial value is float: none, and that's what browsers use as
the default.
And should I define the width to 100%?

No, the initial value is width: auto, and that's what browsers use as
the default. For an inline element (which is what label elements are by
default), the the default means that the element is as wide as needed
for its content.

--
Jukka K. Korpela ("Yucca")http://www.cs.tut.fi/~jkorpela/
Hi,

This is for a form and I am not using tables but a list as follows
(This is ASP.NET MVC Preview 3. Html.TextBox is an Input):

<form id="Edit" action="<%= Url.Action("Upd ate", new { id =
ViewData.Model. Box.BoxID }) %>" method="post" class="Base">
<fieldset>
<legend>Edita r Caixa</legend>
<ol>
<li>
<label for="Name" class="Required ">Nome</label>
<%= Html.TextBox("N ame", (string)ViewDat a["Name"] ??
ViewData.Model. Box.Name.ToStri ng()) %>
</li>
<li>
<label for="Body">Cont eúdo</label>
<%= Html.TextArea(" Body", (string)ViewDat a["Body"] ??
ViewData.Model. Box.Body.ToStri ng(), 10, 20) %>
</li>
</ol>
</fieldset>
</form>

I set the width of the label to push the inputs to the right:

form.Base {}

form.Base fieldset {}

form.Base fieldset legend {display: none;}

form.Base fieldset ol {}

form.Base fieldset ol li {padding: 0.4em 0 0.4em 8em;}

form.Base fieldset ol li input, form.Base fieldset ol li
textarea {
border: solid 4px #F0F0F0; /* #E1EDF0 */
color: #252525;
font: normal 0.8em Verdana, Geneva, sans-serif;
padding: 0.15em;
width: 95%;
}

form.Base fieldset ol li label {
color: #404040;
float: left;
font: bold 0.9em Arial, Helvetica, Tahoma, sans-serif;
margin: 0.3em 0 0 -8em;
padding: 0 1em 0 0;
text-align: right;
width: 6.5em;
}

I am using a JQuery Validation Plugin that displays a error messages
rendered as Labels. These are the ones I want to restyle.

Should I render this error messages with another tag?

Basically I want to give them a red background with padding of 1.2 em
and I don't want them to expand 100% so it shouldn't be a block
element ...

Anyway, any suggestions are welcome to solve this or improve my code.

Thanks,
Miguel
Jun 27 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
6842
by: Peter Collinson | last post by:
Hi... Is there any way to style a List Item a different color and size than the <LI> in an Ordered List? I'd like a red super-script number and a dark blue text in a page's footnotes. And this be done using style sheets? -- - Yours truly, Pete Collinson
20
3002
by: Brian | last post by:
I'm wondering what the group thinks is the best way to display the <label> element. The default rendering in Moz and MSIE/Win (probably others, too) only changes the mouse cursor (that's a strange term) from text-select to default (an arrow). That, to me, is too subtle, and is a bit like "mystery meat" navigation. The user must hover the mouse before they know there was something special. Simon Willison suggested changing the cursor to...
3
4160
by: kpg | last post by:
Here's an easy one. I have an asp:label on a web page. How do I center the text in the label? ??? TIA kpg
5
1992
by: andrew | last post by:
Hello, I have a question about my usage of label as follows.... (sort of a combo html/css question) <p> <label>Field Name</label>Field Data </p> Now I know that a lable is generally associated with a form field, but my
2
7966
by: André Hänsel | last post by:
Hi again, I have a radio button: <p> <input id="v_yes" type="radio" name="v" value="yes" /> <label for="v_yes">Ja</label> <input id="v_no" type="radio" name="v" value="no" /> <label for="v_no">Nein</label> </p>
27
3365
by: Tom Cole | last post by:
I'm starting to do more quantity of javascript coding and thought this might be a good time to investigate code styling. I primarily develop in Java and currently use the code styling techniques spelled out for Java. For example, in my code blocks ( {} ) I always place the starting brace on the same line as the first line of code. For example: function myFunction {
5
59609
by: Yohan Blurp | last post by:
Hi, Here is sample page to show you the problem : <html><body> <form action="/cgi-bin/test.cgi" method="post"> Data Path : <input type="text" size="50" value="C:\Test Data\May 2007.xls" style='border: thin solid #FFFFFF'></form> </body></html>
3
4219
by: Momomo | last post by:
Hi, I am having a problem with a control which is caused by a style on the page which I am not able to trace. If I use the control in a page without any styling it looks ok. Is there a way to remove/turnoff all CSS styling inside a div?
40
2710
by: Jukka K. Korpela | last post by:
My basic style sheet has a distinctive background and border for forms, to make the structure clearer and to make it visually evident what belongs to a form. However, as people complained that some forms were odd-looking, I noticed that indeed, fairly often the background is not applied and there is empty space inside a form I didn't ask for. This was rather puzzling until I realized that the observed cases seem to result from one...
0
9961
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
11181
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10439
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9597
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7990
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6014
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4642
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4245
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3252
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.