Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Sizing a font on a web page

Posted on 2010-08-16
7
688 Views
Last Modified: 2012-05-10
I have a question about setting the font size of text on a web page. When I set a font at "1.65em," for example, it appears at an appropriate size in Visual Studio's design view, but when I preview the page, the font appears significantly smaller. When I use "165%" essentially I get the same results -- it looks right in design view but too small when previewed. Also, regardless of what em or % I use, the font size changes very little compared to the changes I see in design view. The difference in font size between design and preview mode makes using em or % relatively useless. I don't understand why this is. When I use pixels as the unit of measurement design view is very close to the preview. Is there a breif explanation of this phenomenon?
0
Comment
Question by:efz
7 Comments
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 33448437
You should "Request Attention" and get the Visual Studio zone added to your question.  While these things are fairly predictable in the actual web browsers, development packages seem to have their own peculiarities.  If we can get some of the experts that use Visual Studio to look at your question, they can probably help you.
0
 
LVL 9

Expert Comment

by:cb1393
ID: 33448466
Is your doctype declaration the very first line in your code?
0
 
LVL 16

Accepted Solution

by:
s8web earned 500 total points
ID: 33448986
Different browsers apply different default formatting. This is very evident with font sizing. A good practice is to set a base font on your body tag, then use % or em elsewhere to define a percent larger or smaller than what the base size is set at. The perk of this is, if you want to globally increase or decrease the size of your text, you do it by increasing or decreasing the font-size set on the body tag.

Personally, I prefer % instead of em. Em was originally for print media. It means the size of the letter m.

So, long story short if you don't define literally on a global scale (like the body tag) what the percent or em is supposed to be a percent or em of, the browser will take % or em to mean % or em of the browser default text size which is not standardized.
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

Author Comment

by:efz
ID: 33449387
Thank you all for your comments.

s8web, how does one globally define the font size? Do you mean including something in the css style file like below?

body {
  margin: 0px;
  padding: 0px;
  border: 0px;
  outline: 0px;
  font-size: 12pt;
}

Then everytime you use the % measure it would be so many percent of 12, i.e., 150% would be the equivalent of a 18pt font.
0
 
LVL 16

Expert Comment

by:s8web
ID: 33449455
Precisely.
0
 
LVL 9

Expert Comment

by:cb1393
ID: 33451544
For more info that may provide additional clarification on the use of EM, see my 2nd comment on the following page:

http://www.experts-exchange.com/Web_Development/Miscellaneous/Q_23213153.html

As for the trouble you are having in Design View in MSVWD, did you verify whether or not the doctype declaration is on the very first line of code?
0
 
LVL 16

Expert Comment

by:s8web
ID: 33453728
Thanks efz, I missed where you said pt. You might want to use px to declare the font size on the body tag. px is the most specific measure. 1px is 1px like 1 liter is 1 liter. pt can be interpreted in a non-specific manner like em or %.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
tiny glitch in my main slider 3 38
Diminish Pop-up  in 3 seconds 7 44
SSRS 2016 Rendering HTML tables 3 25
Do alert on select 6 13
SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
Use these top 10 tips to master the art of email signature design. Create an email signature design that will easily wow recipients, promote your brand and highlight your professionalism.
In this tutorial viewers will learn how to style a decorative dropcap for the first letter in a paragraph using CSS. In CSS, create a new paragraph class by typing "p.fancy": Then, to style only the first letter of the first sentence, include the ps…
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

789 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question