Press "Enter" to skip to content

What is inheritance in CSS? Use an example to support your answer.


The elements in an XHTML document are structured in a hierarchy of parent and child <html> is the parent element of the document. Parent elements contain nested elements called child elements. Both <head> and <body> are immediate child elements of <html>. <head> and <body> are parent elements as well, because they contain other nested elements. By default, CSS rules are inherited from parent elements to child elements.

Therefore, if you set a style rule for <ul> elements, the <li> elements inherit the style rules, unless you have specifically set a rule for <li>.