473,698 Members | 2,611 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

basic formatting questions

3 New Member
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 1535
Frinavale
9,735 Recognized Expert Moderator Expert
Try this:

<asp:TextBox ID="TextBox1" runat="server" Width="400" Text="AaBbCcDdE eFfGgHhIiJjKkLl MmTt" 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
kmh72756
3 New Member
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 Recognized Expert Moderator Expert
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"...jus t 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 Recognized Expert Expert
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
kmh72756
3 New Member
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 Recognized Expert Expert
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 Recognized Expert Moderator Expert
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 Recognized Expert Expert
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
5185
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 the SQL-related newsgroups seem to be product related. But if I missed something, and someone can steer me to a correct newsgroup, please do so. My specific questions: 1. I want to put comments in an SQL script. For example, I want
3
1671
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 sensitive? 2- Why does not XML allow tag minimization? 3- Why must XML document elements be properly nested? 4- Can you put binary data in a CDATA section?
3
1306
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? let me reword this. what are the essential things I need to make a program webbased using vb.net. If I wrote a program in vb6 that calculate arcade machine sales at each different locations and this info is also saved on the same computer to...
2
1121
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 website, and be able to type in text, give it a colour, fontsize and basic layout, etc. The hit submit, and the text will be available to view through the browser? Cheers,
0
541
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 http://www.geocities.com/myinterviewquestions/ASPAndVisualBasic.htm So please have a look and make use of it.
3
1464
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 tables and keys but i just cant seem to find a "starting point" in VB.net. 1. Where do I go create a db if i only installed vb.net ? / What do I use 2. Or is there a good tutorial somewhere of what to do. I have 3 books and
21
1561
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 basic outline of the program done which is: def Xref(filename): try: fp = open(filename, "r") lines = fp.readlines() fp.close()
2
1299
by: =?Utf-8?B?QWxsYW4gTWljaGFlbHM=?= | last post by:
Hello, I have some basic questions regarding Icons. The ms-help page for System.Drawing.Icon ms-help://MS.VSCC.v80/MS.MSDN.v80/MS.NETDEVFX.v20.en/cpref8/html/T_System_Drawing_Icon_Members.htm says that "Icons can be thought of as transparent bitmaps, although their size is determined by the system."
5
9360
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 my own dedicated machine I plan to use as a server. I don't expect detailed answers to these questions (though that would be appreciated), so if someone can point me to articles/forums that give good answers (have had trouble finding info for pure...
3
1520
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 have a thread whose job is to send several emails (i.e. a long task that mustn't be run by more that one user at a time). It all works fine, but I am concerned about the lifetime of a thread in the case of smtp errors, and how it will work with...
0
8610
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9031
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...
0
8873
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
7740
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
5862
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
4372
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4623
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3052
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
3
2007
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.