Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Sizing a font on a web page

Posted on 2010-08-16
7
Medium Priority
?
718 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
[X]
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
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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

636 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