Physical Address
Godawari 2 Attariya Kailali
Physical Address
Godawari 2 Attariya Kailali
We can set up style rules for our page based on how tags are nested inside another tag(Define Styles For Nested Tags). For example, we can specify that a style rule is applied to the heading tag, but only when that heading is nested inside a certain type of section tag. We create such a style rule by specifying a sequence of tags or tag classes in the selector. The nested order of tags on your page must match the sequence of the tags in the selector for the style to be applied. Defining style rules this way enables you to efficiently apply a style to precise sections of your page.
Define the style
Apply the style
Type the outer tag. Add a class attribute if one was defined in the style.
<!DOCTYPE html> <html> <Head> <Title>Coding thai</Title> <style> Section.First h2{ color: red; font-family: arial; font-style: italic; } </style> </Head> <body> <h1>Types of Web Developer</h1> <hr> <Section class="First"> <h2>Fontend Developer</h2> <p>A front end developer has one general responsibility: to ensure that website visitors can easily interact with the page. </p> </Section> <Section class="Second"> <h2>Back-end Developer</h2> <p>Back-end developers are the experts who build and maintain the mechanisms that process data and perform actions on websites.</p> </Section> <hr> <small> ©Copyright 2022 Codingthai</small> </body> </html>
We can use family tree terminology. The outer tags are known as ancestors and the inner tags are known as descendants. In the example above the <h1> tag must be a descendant of the <section> tag for the style to be applied.
Tags directly next to each other in the hierarchy can be given more specific classifications. The outer tag is a parent and the next tag immediately on the inside is a child.
We can specify that a style rule is applied only to the immediate descendant or child of a tag using a greater than symbol(>) in the selector. The following applies a rule for a <p> tag that is directly inside of a < article> tag:
Article >p { font-size: 16pz; color:green}
This rule would apply to the following:
<article><p>Hello, HTML5!</p></article>
The rule would not apply to the following:
<Article><section><p>Hello, HTML5!</p> </sectin></article>
Facebook, Instagram, Pinterest