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.










share|improve this question


















  • 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

















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.










share|improve this question


















  • 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















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.










share|improve this question













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






share|improve this question













share|improve this question











share|improve this question




share|improve this question










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
















  • 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














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>








share|improve this answer























  • 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











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














 

draft saved


draft discarded


















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

























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>








share|improve this answer























  • 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















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>








share|improve this answer























  • 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













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>








share|improve this answer














'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>






share|improve this answer














share|improve this answer



share|improve this answer








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


















  • 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


















 

draft saved


draft discarded



















































 


draft saved


draft discarded














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





















































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







Popular posts from this blog

Biblatex bibliography style without URLs when DOI exists (in Overleaf with Zotero bibliography)

ComboBox Display Member on multiple fields

Is it possible to collect Nectar points via Trainline?