473,412 Members | 2,174 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,412 software developers and data experts.

basic formatting questions

I'm having trouble getting some basic understandings of how web pages, specifically developed using Visual Studio 2008, are constructed.

The code below started as an empty Default.aspx page to which I added only an asp:Label and an asp:TextBox.
When I added only a font-family to the <body>, the font of the TextBox doesn't change. Why not?

The actual browser I'm starting with is IE8 and I have seen slight differences from trying to use FireFox. But I don't even want to begin talking about browser inconsistencies yet.

On another message board, someone suggested adding a set of reset CSS which I obtained from Eric Meyer's site. That didn't make any difference and I don't really see why it was suggested.

I believe that, whatever the concept is that I am missing, it lies at the base of understanding web pages in general, and CSS in particular.

Can anyone point out what I'm missing or doing wrong?

Here's the code:
Expand|Select|Wrap|Line Numbers
  1. <%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Default.aspx.vb" Inherits="TestDefaults._Default" %> 
  2.  
  3. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
  4.  
  5. <html xmlns="http://www.w3.org/1999/xhtml" > 
  6. <head runat="server"> 
  7.     <style type="text/css"> 
  8.         /* http://meyerweb.com/eric/tools/css/reset/  
  9.         v2.0 | 20110126 
  10.         License: none (public domain) 
  11.         */ 
  12.  
  13.         html, body, div, span, applet, object, iframe, 
  14.         h1, h2, h3, h4, h5, h6, p, blockquote, pre, 
  15.         a, abbr, acronym, address, big, cite, code, 
  16.         del, dfn, em, img, ins, kbd, q, s, samp, 
  17.         small, strike, strong, sub, sup, tt, var, 
  18.         b, u, i, center, 
  19.         dl, dt, dd, ol, ul, li, 
  20.         fieldset, form, label, legend, 
  21.         table, caption, tbody, tfoot, thead, tr, th, td, 
  22.         article, aside, canvas, details, embed,  
  23.         figure, figcaption, footer, header, hgroup,  
  24.         menu, nav, output, ruby, section, summary, 
  25.         time, mark, audio, video { 
  26.                 margin: 0; 
  27.                 padding: 0; 
  28.                 border: 0; 
  29.                 font-size: 100%; 
  30.                 font: inherit; 
  31.                 vertical-align: baseline; 
  32.         } 
  33.         /* HTML5 display-role reset for older browsers */ 
  34.         article, aside, details, figcaption, figure,  
  35.         footer, header, hgroup, menu, nav, section { 
  36.                 display: block; 
  37.         } 
  38.         body { 
  39.                 line-height: 1; 
  40.         } 
  41.         ol, ul { 
  42.                 list-style: none; 
  43.         } 
  44.         blockquote, q { 
  45.                 quotes: none; 
  46.         } 
  47.         blockquote:before, blockquote:after, 
  48.         q:before, q:after { 
  49.                 content: ''; 
  50.                 content: none; 
  51.         } 
  52.         table { 
  53.                 border-collapse: collapse; 
  54.                 border-spacing: 0; 
  55.         } 
  56.     </style> 
  57.     <title></title> 
  58. </head> 
  59. <body> 
  60.     <form id="form1" runat="server" style="font-family: 'Trebuchet MS', Helvetica, Sans-Serif;"> 
  61.     <div> 
  62.          <asp:Label ID="Label1" runat="server" Text="AaBbCcDdEeFfGgHhIiJjKkLlMmTt" /> 
  63.          <br /> 
  64.          <asp:TextBox ID="TextBox1" runat="server" Width="400" Text="AaBbCcDdEeFfGgHhIiJjKkLlMmTt" /> 
  65.     </div> 
  66.     </form> 
  67. </body> 
  68. </html> 
  69.  
  70.  
Sep 5 '11 #1
8 1526
Frinavale
9,735 Expert Mod 8TB
Try this:

<asp:TextBox ID="TextBox1" runat="server" Width="400" Text="AaBbCcDdEeFfGgHhIiJjKkLlMmTt" style="font-family: 'Trebuchet MS', Helvetica, Sans-Serif;" />

Let me know if it works for you...if it does we can create a css style that target's "input" elements (which is what your textbox renders as).
Sep 8 '11 #2
Thank you but yes, I understand that I can 'fix' the textbox directly.

But my question is why doesn't the textbox pay attention to the font-family already specified on the form?

Why is it at all necessary to add another style attribute to the textbox when there is already one on the form which contains the textbox?

How can they be called 'cascading' style sheets if they don't cascade?

By extension, I could conceivably specify every possible property on every single control, but that's just silly.

How can I understand what attributes need to be specified and what inheritances will work or not when this simple example doesn't work?
Sep 9 '11 #3
Frinavale
9,735 Expert Mod 8TB
I'm not really sure why the HTML <input type="text" /> is not styled when you set the font-family for the parent element.

It has something to do with the browser's implementation.
CSS styles still "cascade"...just some controls are implemented differently than others and you have to implement styles with that in mind.

-Frinny

(PS I'm moving this to the HTML forum where you may get a better answer)
Sep 9 '11 #4
drhowarddrfine
7,435 Expert 4TB
When I added only a font-family to the <body>, the font of the TextBox doesn't change. Why not?
Because you change the font-family on the form. That should cascade to the following elements within the form.

The actual browser I'm starting with is IE8 and I have seen slight differences from trying to use FireFox. But I don't even want to begin talking about browser inconsistencies yet.
Start now or you'll be ruined for life. Never, EVER use IE as a reference browser during testing. It is inept, years behind all others in modern standards and practices and the worst browser on the planet by far. Always, ALWAYS use a modern browser, ANYTHING but IE, to initially test your markup. Then you know your code is good and should work in all modern browsers but the multitude of problems with IE are known, as are the hacks to fix it. Never, EVER trust IE to do ANYTHING right!

You are using the transitional doctype. New web pages have no use for that. Always use strict.
Sep 9 '11 #5
I've been trying so many things from different forums that my text didn't match up with the actual code.

As you can see, I did put the font-family on the form, not the body.
That didn't help either.

How do I get control of the doctype with ASP.Net?

As far as browser choice goes, I'm just the architect and developer. The customer controls what the browser platform is. In this case, they are insisting on IE, so it doesn't matter whether my coding looks good in any other.
Sep 9 '11 #6
drhowarddrfine
7,435 Expert 4TB
Then the issue may be caused by when ASP creates the HTML vs when the browser styles with the CSS though I don't think that's the issue. My opinion of asp.net is just as low as that of IE. Can you post the *generated* markup or provide a link?
How do I get control of the doctype with ASP.Net?
Don't know. That's a question for the other board.
The customer controls what the browser platform is. In this case, they are insisting on IE
Yes. I've had many an uneducated customer in my time.
Sep 9 '11 #7
Frinavale
9,735 Expert Mod 8TB
The issue is not caused when ASP creates the HTML.
TextBoxes are simply rendered as <input type="text"> with an ID and maybe some JavaScript that is executed when the focus is taken off of the control (if you have AutoPostback set on the ASP.NET TextBox control).

It's just a styling thing that needs to be addressed.

If you are required to support IE then you need to create extra styling that addresses IE specific styling needs. There are ways to do this without making the HTML invalid too.

It's really not that hard to create a style for type input that sets the font-family.

For example:
Expand|Select|Wrap|Line Numbers
  1. <style type="text/css">
  2.   body
  3.   {
  4.     font-family:  'Trebuchet MS', Helvetica, Sans-Serif;
  5.   }
  6.   input
  7.   {
  8.     font-family: 'Trebuchet MS', Helvetica, Sans-Serif;
  9.   }
  10. </style>
Or even:
Expand|Select|Wrap|Line Numbers
  1. <style type="text/css">
  2.   body, input
  3.   {
  4.     font-family:  'Trebuchet MS', Helvetica, Sans-Serif;
  5.   }
  6. </style>

I do not recommend changing the doc-type in ASP.NET either...I tried once (hehe bad idea)...if you Really want to try, then simply open the page (or the MasterPage if you're using them) and change the doctype. But be aware that it will cause problems.

-Frinny
Sep 9 '11 #8
drhowarddrfine
7,435 Expert 4TB
I thought the question was why the styling isn't being applied even though he entered it into the form element.

EDIT: I think the problem lies in that we're trying to style the input text from the form element. Apparently that doesn't work but I don't remember the rule for when that gets applied. It does work if you apply it directly to the input tag but not the form so obviously I've forgotten how this works.
Sep 9 '11 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Steven O. | last post by:
First, this may not be the correct newsgroup. I have some relatively basic questions on SQL. I tried to find a newsgroup that was specifically just about SQL, and was surprised to find that all...
3
by: Unal | last post by:
Hi, I have couple of simple questions about XML that I cannot find answers to in the book I looked at and in the search I did on internet. Can anyone help me with these? 1- Why is XML case...
3
by: Newbee Adam | last post by:
If I program in vb.net will my program be accessible via a browser, or do I need to use the webbrowser active x control like in vb 6. would the program reside on a webserver like IIS or apache? ...
2
by: Jack | last post by:
Hi all, Is there a way for a user of a website to control the basic font size/colour of text, then upload it into a HTML text page in ASP.NET 1.1 ? For example, I want a user to log into the...
0
by: software2006 | last post by:
ASP And Visual Basic Interview questions and answers I have listed over 100 ASP and Visual Basic interview questions and answers in my website...
3
by: Miro | last post by:
Ok im a newbie to VB, and am having some trouble reading msdn help / or how it all links together. My books are either missing a step / or assume everything is set up correctly. I know about...
21
by: nateastle | last post by:
I have a simple assignment for school but am unsure where to go. The assignment is to read in a text file, split out the words and say which line each word appears in alphabetical order. I have the...
2
by: =?Utf-8?B?QWxsYW4gTWljaGFlbHM=?= | last post by:
Hello, I have some basic questions regarding Icons. The ms-help page for System.Drawing.Icon ...
5
by: patricio2626 | last post by:
Hi all, Sorry about the noobish question, but I guess we all have to start somewhere. I just bought a domain (non-hosted) from GoDadday, and plan on hosting myself, for the experience. I have...
3
by: JJ | last post by:
I've done a little multi-threading on winform apps some time ago now, so I'm not a complete beginner, but best assume I am for any explanations..: This is an asp.net 2.0 website, using c#: I...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...
0
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...
0
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...

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.