Why and How font sizes specified in HTML and CSS as "small" and "x-large" work together!? | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
+ 2

Why and How font sizes specified in HTML and CSS as "small" and "x-large" work together!?

When we write in HTML <p class="small"> Para in small <\p> And in CSS p.small { font-size: x-large; } The output comes out In X-large!! So which is the deciding factor!? https://code.sololearn.com/Ws17uyxjIWj5/?ref=app

26th May 2019, 3:53 PM
Gaurav Raghuwanshi
Gaurav Raghuwanshi - avatar
2 Respostas
+ 4
The class name doesn't matter, it could be anything; the content of it counts
26th May 2019, 4:31 PM
Airree
Airree - avatar
+ 1
Yes the class=ā€œsmallā€ is a container word, like in Algebra, X=whatever. So ā€˜smallā€™ in this situation is a container word. You then tell the browser using CSS what ā€˜smallā€™ means, in this case your telling the browser small means ā€˜x-largeā€™ so now every time the browser sees the word ā€˜smallā€™ in your HTML it knows to make your text x-large, because you told it to in your CSS. In this solo learn app, making the class name ā€˜smallā€™ when your actually assigning the size in your CSS, makes the class name alittle bit deceptive because the class name doesnā€™t mean anything, it can be, essentially, whatever you want it to be. It could be class=ā€œbananasā€ as long as your CSS assigns the desired attributes bananas can mean whatever you want it to mean. So this: HTML <p class=ā€œbananasForYouā€> This is my text </p> CSS p.bananasForYou { font-size: x-large; } this will also make your text X-large. The reason why they use class=ā€œsmallā€ in HTML and then in your CSS font-size: small; is to make your code a little eaiser to read/navigate. Especially if someone else is reviewing your code.
1st Aug 2019, 9:40 PM
Brian Coates
Brian Coates - avatar