Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Sizing a font on a web page

Posted on 2010-08-16
7
Medium Priority
?
722 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 84

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 2000 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

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

Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
This article discusses four methods for overlaying images in a container on a web page
In this tutorial viewers will learn how to embed custom externally-hosted Google Fonts using the Google Font API in CSS Go to the Google Fonts website at google.com/fonts: Browse or search based on font properties or name to find a suitable font for…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

810 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