473,791 Members | 3,015 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 2457
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
6838
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
2984
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
4156
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
1987
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
7961
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
3356
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
59599
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
4214
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
2685
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
9669
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
10207
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10155
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9029
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...
0
6776
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5559
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4110
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
3718
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2916
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.