Scaling down font-size using lang css directive gives weird results
up vote
1
down vote
favorite
I am creating multilingual site and I have realized that some languages such as French are quite wordy which breaks my design which was done using English copy. So I have been trying to use the :lang
css directive mainly to reduce the font-size across the board for French landing page. But the results are quite counter-intuitive. A percentage reduction by a small amount results in a big reduction in actual size.
Perhaps my understanding is incorrect. Here is an example code that explains this phenomenon
:lang(fr)
{
font-size:90%;
}
h1 {
font-size:3em;
}
<h1>
This is my heading
</h1>
<h1 lang="fr">
This is my very very long verbose heading in French
</h1>
As you can see, my French headline became very small with only 10% reduction in font-size.
html css html5 css3
add a comment |
up vote
1
down vote
favorite
I am creating multilingual site and I have realized that some languages such as French are quite wordy which breaks my design which was done using English copy. So I have been trying to use the :lang
css directive mainly to reduce the font-size across the board for French landing page. But the results are quite counter-intuitive. A percentage reduction by a small amount results in a big reduction in actual size.
Perhaps my understanding is incorrect. Here is an example code that explains this phenomenon
:lang(fr)
{
font-size:90%;
}
h1 {
font-size:3em;
}
<h1>
This is my heading
</h1>
<h1 lang="fr">
This is my very very long verbose heading in French
</h1>
As you can see, my French headline became very small with only 10% reduction in font-size.
html css html5 css3
1
What's wrong here, I think it is working as expected. Your french lang showing 90% by inheriting from your parent tag body. Until we set any font-size for body browsers may set the size 16px (in chrome) and :lang(fr) selector showing 90% of 16px. Keep it mind percentage inherit from parent container not from siblings.
– Hanif
Nov 13 at 1:54
add a comment |
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I am creating multilingual site and I have realized that some languages such as French are quite wordy which breaks my design which was done using English copy. So I have been trying to use the :lang
css directive mainly to reduce the font-size across the board for French landing page. But the results are quite counter-intuitive. A percentage reduction by a small amount results in a big reduction in actual size.
Perhaps my understanding is incorrect. Here is an example code that explains this phenomenon
:lang(fr)
{
font-size:90%;
}
h1 {
font-size:3em;
}
<h1>
This is my heading
</h1>
<h1 lang="fr">
This is my very very long verbose heading in French
</h1>
As you can see, my French headline became very small with only 10% reduction in font-size.
html css html5 css3
I am creating multilingual site and I have realized that some languages such as French are quite wordy which breaks my design which was done using English copy. So I have been trying to use the :lang
css directive mainly to reduce the font-size across the board for French landing page. But the results are quite counter-intuitive. A percentage reduction by a small amount results in a big reduction in actual size.
Perhaps my understanding is incorrect. Here is an example code that explains this phenomenon
:lang(fr)
{
font-size:90%;
}
h1 {
font-size:3em;
}
<h1>
This is my heading
</h1>
<h1 lang="fr">
This is my very very long verbose heading in French
</h1>
As you can see, my French headline became very small with only 10% reduction in font-size.
:lang(fr)
{
font-size:90%;
}
h1 {
font-size:3em;
}
<h1>
This is my heading
</h1>
<h1 lang="fr">
This is my very very long verbose heading in French
</h1>
:lang(fr)
{
font-size:90%;
}
h1 {
font-size:3em;
}
<h1>
This is my heading
</h1>
<h1 lang="fr">
This is my very very long verbose heading in French
</h1>
html css html5 css3
html css html5 css3
asked Nov 13 at 1:01
hvs
128111
128111
1
What's wrong here, I think it is working as expected. Your french lang showing 90% by inheriting from your parent tag body. Until we set any font-size for body browsers may set the size 16px (in chrome) and :lang(fr) selector showing 90% of 16px. Keep it mind percentage inherit from parent container not from siblings.
– Hanif
Nov 13 at 1:54
add a comment |
1
What's wrong here, I think it is working as expected. Your french lang showing 90% by inheriting from your parent tag body. Until we set any font-size for body browsers may set the size 16px (in chrome) and :lang(fr) selector showing 90% of 16px. Keep it mind percentage inherit from parent container not from siblings.
– Hanif
Nov 13 at 1:54
1
1
What's wrong here, I think it is working as expected. Your french lang showing 90% by inheriting from your parent tag body. Until we set any font-size for body browsers may set the size 16px (in chrome) and :lang(fr) selector showing 90% of 16px. Keep it mind percentage inherit from parent container not from siblings.
– Hanif
Nov 13 at 1:54
What's wrong here, I think it is working as expected. Your french lang showing 90% by inheriting from your parent tag body. Until we set any font-size for body browsers may set the size 16px (in chrome) and :lang(fr) selector showing 90% of 16px. Keep it mind percentage inherit from parent container not from siblings.
– Hanif
Nov 13 at 1:54
add a comment |
1 Answer
1
active
oldest
votes
up vote
1
down vote
accepted
'Perhaps my understanding is incorrect." yes I think so. You expecting font size for French will show 90% of 3em which you defined for h1 { font-size:3em;}
.
But keep your mind when you set something like that font-size:90%
means font size will inherit 90% from immediate parent where we already set the font size. From your given code you not set the font size for <h1 lang="fr">
container (in this case it is 'body').
If we not set the font-size for body browser by default set 16px (in chrome but it can vary browser to browser). So pseudo-class :lang(fr)
selector is higher priority than only tag selector h1
and it is inheriting from it's container body tag means "14.4px".
My suggestion is to overcome this situation apply the em
unit. em
unit inherit from top most parent. See following approach, it may be can give you a way.
body {
font-size: 16px;
}
h1 {
font-size:3em; /* means 16*3 = 48px; */
}
h1:lang(fr) {
font-size:2.7em; /* (48*90)/100 = 43.2px/16px = 2.7em */
}
<h1>Actual Font Size</h1>
<h1 lang="fr">French Font Size</h1>
I knew I was wrong in my understanding :) Thanks for your detailed explanation.
– hvs
Nov 13 at 21:07
While I did understand your explanation, what is the best solution for the issue I am facing with some languages. If you can suggest something, it would be greatly helpful. Thanks.
– hvs
Nov 13 at 21:09
1
I have updated my answer it may be helpful for you.
– Hanif
Nov 13 at 21:52
1
Thank you so much. I wish I could give you more upvote!
– hvs
Nov 14 at 21:54
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
accepted
'Perhaps my understanding is incorrect." yes I think so. You expecting font size for French will show 90% of 3em which you defined for h1 { font-size:3em;}
.
But keep your mind when you set something like that font-size:90%
means font size will inherit 90% from immediate parent where we already set the font size. From your given code you not set the font size for <h1 lang="fr">
container (in this case it is 'body').
If we not set the font-size for body browser by default set 16px (in chrome but it can vary browser to browser). So pseudo-class :lang(fr)
selector is higher priority than only tag selector h1
and it is inheriting from it's container body tag means "14.4px".
My suggestion is to overcome this situation apply the em
unit. em
unit inherit from top most parent. See following approach, it may be can give you a way.
body {
font-size: 16px;
}
h1 {
font-size:3em; /* means 16*3 = 48px; */
}
h1:lang(fr) {
font-size:2.7em; /* (48*90)/100 = 43.2px/16px = 2.7em */
}
<h1>Actual Font Size</h1>
<h1 lang="fr">French Font Size</h1>
I knew I was wrong in my understanding :) Thanks for your detailed explanation.
– hvs
Nov 13 at 21:07
While I did understand your explanation, what is the best solution for the issue I am facing with some languages. If you can suggest something, it would be greatly helpful. Thanks.
– hvs
Nov 13 at 21:09
1
I have updated my answer it may be helpful for you.
– Hanif
Nov 13 at 21:52
1
Thank you so much. I wish I could give you more upvote!
– hvs
Nov 14 at 21:54
add a comment |
up vote
1
down vote
accepted
'Perhaps my understanding is incorrect." yes I think so. You expecting font size for French will show 90% of 3em which you defined for h1 { font-size:3em;}
.
But keep your mind when you set something like that font-size:90%
means font size will inherit 90% from immediate parent where we already set the font size. From your given code you not set the font size for <h1 lang="fr">
container (in this case it is 'body').
If we not set the font-size for body browser by default set 16px (in chrome but it can vary browser to browser). So pseudo-class :lang(fr)
selector is higher priority than only tag selector h1
and it is inheriting from it's container body tag means "14.4px".
My suggestion is to overcome this situation apply the em
unit. em
unit inherit from top most parent. See following approach, it may be can give you a way.
body {
font-size: 16px;
}
h1 {
font-size:3em; /* means 16*3 = 48px; */
}
h1:lang(fr) {
font-size:2.7em; /* (48*90)/100 = 43.2px/16px = 2.7em */
}
<h1>Actual Font Size</h1>
<h1 lang="fr">French Font Size</h1>
I knew I was wrong in my understanding :) Thanks for your detailed explanation.
– hvs
Nov 13 at 21:07
While I did understand your explanation, what is the best solution for the issue I am facing with some languages. If you can suggest something, it would be greatly helpful. Thanks.
– hvs
Nov 13 at 21:09
1
I have updated my answer it may be helpful for you.
– Hanif
Nov 13 at 21:52
1
Thank you so much. I wish I could give you more upvote!
– hvs
Nov 14 at 21:54
add a comment |
up vote
1
down vote
accepted
up vote
1
down vote
accepted
'Perhaps my understanding is incorrect." yes I think so. You expecting font size for French will show 90% of 3em which you defined for h1 { font-size:3em;}
.
But keep your mind when you set something like that font-size:90%
means font size will inherit 90% from immediate parent where we already set the font size. From your given code you not set the font size for <h1 lang="fr">
container (in this case it is 'body').
If we not set the font-size for body browser by default set 16px (in chrome but it can vary browser to browser). So pseudo-class :lang(fr)
selector is higher priority than only tag selector h1
and it is inheriting from it's container body tag means "14.4px".
My suggestion is to overcome this situation apply the em
unit. em
unit inherit from top most parent. See following approach, it may be can give you a way.
body {
font-size: 16px;
}
h1 {
font-size:3em; /* means 16*3 = 48px; */
}
h1:lang(fr) {
font-size:2.7em; /* (48*90)/100 = 43.2px/16px = 2.7em */
}
<h1>Actual Font Size</h1>
<h1 lang="fr">French Font Size</h1>
'Perhaps my understanding is incorrect." yes I think so. You expecting font size for French will show 90% of 3em which you defined for h1 { font-size:3em;}
.
But keep your mind when you set something like that font-size:90%
means font size will inherit 90% from immediate parent where we already set the font size. From your given code you not set the font size for <h1 lang="fr">
container (in this case it is 'body').
If we not set the font-size for body browser by default set 16px (in chrome but it can vary browser to browser). So pseudo-class :lang(fr)
selector is higher priority than only tag selector h1
and it is inheriting from it's container body tag means "14.4px".
My suggestion is to overcome this situation apply the em
unit. em
unit inherit from top most parent. See following approach, it may be can give you a way.
body {
font-size: 16px;
}
h1 {
font-size:3em; /* means 16*3 = 48px; */
}
h1:lang(fr) {
font-size:2.7em; /* (48*90)/100 = 43.2px/16px = 2.7em */
}
<h1>Actual Font Size</h1>
<h1 lang="fr">French Font Size</h1>
body {
font-size: 16px;
}
h1 {
font-size:3em; /* means 16*3 = 48px; */
}
h1:lang(fr) {
font-size:2.7em; /* (48*90)/100 = 43.2px/16px = 2.7em */
}
<h1>Actual Font Size</h1>
<h1 lang="fr">French Font Size</h1>
body {
font-size: 16px;
}
h1 {
font-size:3em; /* means 16*3 = 48px; */
}
h1:lang(fr) {
font-size:2.7em; /* (48*90)/100 = 43.2px/16px = 2.7em */
}
<h1>Actual Font Size</h1>
<h1 lang="fr">French Font Size</h1>
edited Nov 13 at 21:51
answered Nov 13 at 2:12
Hanif
2,4941511
2,4941511
I knew I was wrong in my understanding :) Thanks for your detailed explanation.
– hvs
Nov 13 at 21:07
While I did understand your explanation, what is the best solution for the issue I am facing with some languages. If you can suggest something, it would be greatly helpful. Thanks.
– hvs
Nov 13 at 21:09
1
I have updated my answer it may be helpful for you.
– Hanif
Nov 13 at 21:52
1
Thank you so much. I wish I could give you more upvote!
– hvs
Nov 14 at 21:54
add a comment |
I knew I was wrong in my understanding :) Thanks for your detailed explanation.
– hvs
Nov 13 at 21:07
While I did understand your explanation, what is the best solution for the issue I am facing with some languages. If you can suggest something, it would be greatly helpful. Thanks.
– hvs
Nov 13 at 21:09
1
I have updated my answer it may be helpful for you.
– Hanif
Nov 13 at 21:52
1
Thank you so much. I wish I could give you more upvote!
– hvs
Nov 14 at 21:54
I knew I was wrong in my understanding :) Thanks for your detailed explanation.
– hvs
Nov 13 at 21:07
I knew I was wrong in my understanding :) Thanks for your detailed explanation.
– hvs
Nov 13 at 21:07
While I did understand your explanation, what is the best solution for the issue I am facing with some languages. If you can suggest something, it would be greatly helpful. Thanks.
– hvs
Nov 13 at 21:09
While I did understand your explanation, what is the best solution for the issue I am facing with some languages. If you can suggest something, it would be greatly helpful. Thanks.
– hvs
Nov 13 at 21:09
1
1
I have updated my answer it may be helpful for you.
– Hanif
Nov 13 at 21:52
I have updated my answer it may be helpful for you.
– Hanif
Nov 13 at 21:52
1
1
Thank you so much. I wish I could give you more upvote!
– hvs
Nov 14 at 21:54
Thank you so much. I wish I could give you more upvote!
– hvs
Nov 14 at 21:54
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53272274%2fscaling-down-font-size-using-lang-css-directive-gives-weird-results%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
What's wrong here, I think it is working as expected. Your french lang showing 90% by inheriting from your parent tag body. Until we set any font-size for body browsers may set the size 16px (in chrome) and :lang(fr) selector showing 90% of 16px. Keep it mind percentage inherit from parent container not from siblings.
– Hanif
Nov 13 at 1:54