Solved

Sizing a font on a web page

Posted on 2010-08-16
7
663 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 82

Expert Comment

by:Dave Baldwin
Comment Utility
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
Comment Utility
Is your doctype declaration the very first line in your code?
0
 
LVL 16

Accepted Solution

by:
s8web earned 500 total points
Comment Utility
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

Author Comment

by:efz
Comment Utility
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
Comment Utility
Precisely.
0
 
LVL 9

Expert Comment

by:cb1393
Comment Utility
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
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

CSS is a visual language used to classify objects and define rules about how they should be displayed. CSS skills aren’t restricted to developers anymore, there is a big benefit to having a basic understanding of the language, regardless of your occ…
Why do we like using grid based layouts in website design? Let's look at the live examples of websites and compare them to grid based WordPress themes.
In this tutorial viewers will learn how to style transparent/translucent elements using alpha transparency in CSS Start with a normal styled element, such as a div.: Define its "background-color" property as "rgba (255, 255, 255, .5): The numbers in…
In this tutorial viewers will learn how to customize the background color and font color of highlighted text using the ::selection element in CSS Begin by defining the selected text as an element in CSS by typing "::selection": Style the ::selection…

728 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now