![]() |
#1 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,086
Karma: 6719822
Join Date: Jul 2012
Device: Palm Pilot M105
|
confused about style inheritance
I thought that styling applied to upper level tags was inherited by tags that were enclosed in them. E.g., any styling on the html tag would be inherited by the body tag and/or any styling on the body tag would be inherited by the p tags. But that doesn't seem to be the case. My css file contains
Code:
body { font-size: 100%; border-bottom: 0; border-top: 0; margin-bottom: 0; margin-top: 0; padding-bottom: 0; padding-top: 0; } p { display: block; font-size: 1em; text-indent: 1.5em; text-align: left; } Can someone explain to me what's going on? |
![]() |
![]() |
![]() |
#2 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 7,070
Karma: 91577715
Join Date: Nov 2011
Location: Charlottesville, VA
Device: Kindles
|
It is more complicated than you think. Read a CSS tutorial.
Margins and padding are not inherited. Font-size can be inherited. 100% means make it the same as its parent element’s font size, which is the default anyway. Last edited by jhowell; 05-13-2019 at 10:21 PM. |
![]() |
![]() |
Advert | |
|
![]() |
#3 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,086
Karma: 6719822
Join Date: Jul 2012
Device: Palm Pilot M105
|
|
![]() |
![]() |
![]() |
#4 |
A Hairy Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 3,348
Karma: 20171571
Join Date: Dec 2012
Location: Charleston, SC today
Device: iPhone 15/11/X/6/iPad 1,2,Air & Air Pro/Surface Pro/Kindle PW & Fire
|
Hi,
Generally, when you define an element like you did, you are defining each element's attributes (it's box model: margin, border, padding, etc.). You are not defining it's child element's. If you want a specific attribute to inherit from it's parent you need to set it to 'inherit'. eg. Code:
p {color: inherit} Having said that, when you set the body font-size to 100% your are setting the baseline font size for the document. When you then define font-size within a child element using EMs then that is relative to the font-size you set in the body. Clear as mud? 1em = 1 times the size you set in body 1.2em = 1.2 times the size you set in the body 2em = 2 times, etc. That way, when a browser/reader/app changes the overall font size, then each font remains the same size relative to each other, ie the header will still stay 1.2 times the size of the normal paragraph font size if you used the following css: Code:
body {font-size: 100%; margin: 0; padding: 0; border: 0} h1 {font-size: 1.2em; font-weight: bold} p {font-size: 1em} |
![]() |
![]() |
![]() |
#5 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,086
Karma: 6719822
Join Date: Jul 2012
Device: Palm Pilot M105
|
Ok, thanks. So it sounds like what some people have said in this thread isn't correct:
https://www.mobileread.com/forums/sh...d.php?t=316965 |
![]() |
![]() |
Advert | |
|
![]() |
#6 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,086
Karma: 6719822
Join Date: Jul 2012
Device: Palm Pilot M105
|
|
![]() |
![]() |
![]() |
#7 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 7,070
Karma: 91577715
Join Date: Nov 2011
Location: Charlottesville, VA
Device: Kindles
|
|
![]() |
![]() |
![]() |
#8 |
A Hairy Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 3,348
Karma: 20171571
Join Date: Dec 2012
Location: Charleston, SC today
Device: iPhone 15/11/X/6/iPad 1,2,Air & Air Pro/Surface Pro/Kindle PW & Fire
|
|
![]() |
![]() |
![]() |
#9 | |
A Hairy Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 3,348
Karma: 20171571
Join Date: Dec 2012
Location: Charleston, SC today
Device: iPhone 15/11/X/6/iPad 1,2,Air & Air Pro/Surface Pro/Kindle PW & Fire
|
Quote:
There was a lot of discussion in that thread about how to fix a specific rendering issue with a specific piece of software using negative margins. Be careful when using someone's work-around as a template for all styling! lolz |
|
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Style Sheet entry for a 'hanging' style | AThirstyMind | Kindle Formats | 6 | 12-10-2016 12:28 AM |
Christopher Paolini, Inheritance Cycle | Joy736 | Reading Recommendations | 8 | 02-04-2012 07:28 PM |
Inheritance 4 Paolini, no ePub books? | mclien | General Discussions | 27 | 11-13-2011 10:46 AM |
Mobi TOC style vs ePub style? | phearlez | Kindle Formats | 3 | 04-11-2010 06:35 AM |
Brisingr/Inheritance discussion (spoilers) | nekokami | Reading Recommendations | 6 | 01-15-2009 10:22 AM |