Welcome to Bucaro TecHelp!

Bucaro TecHelp
HTTPS Encryption not required because no account numbers or
personal information is ever requested or accepted by this site

About Bucaro TecHelp About BTH User Agreement User Agreement Privacy Policy Privacy Site Map Site Map Contact Bucaro TecHelp Contact RSS News Feeds News Feeds

Context selectors

When creating a web page it is often required to put one tag into another. In order to use these tags correctly, use selectors, which work only in the certain context. For example, defining the style for tag <B> only when it is located in the paragraph <P>. The Contextual selector consists of simple selectors which are separated with space.


Tag1 Tag2 { ... }

In this case style will be applied to the Tag2, when it is located in the Tag1, as it is shown below.

<Tag2> ... </Tag>

The usage of contextual selectors is shown in the example 9.1.

Example 9.1. Contextual selectors.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
  <meta http-equiv="Content-Type" content="text/html; charset=windows-1251">
  <title>Contextual selectors</title>
  <style type="text/css">
   P B { 
    font-family: Times, serif; /* Font family */
    font-weight: bold; /* heavy faced type*/
    color: navy; /* blue colour of the text */
   <div><b>heavy faced type</b></div>
   <p><b>The heavy faced type of the text and text highlighting takes part simultaneously</b></p>

In this example we see the common use of the tag <B> and its use, when it is put into paragraph <P>. The color of the text and font are changed, as it is shown in the figure 9.1.

Example of CSS Contextual selectors

Figure 9.1. Design of the text, depends on the nesting of tags.

Note: It is not obligatory that context selectors consist of only one embedded tag. Depending on the situation it is supposed to apply one and more than one tags, logically embedded into each other. When using classes and identifiers, contextual selectors give more capacities. It allows defining the style only for that element, which is located in the certain class, as it is shown in the example.

RSS Feed RSS Feed

Follow Stephen Bucaro Follow @Stephen Bucaro

Fire HD
[Site User Agreement] [Privacy Policy] [Site map] [Search This Site] [Contact Form]
Copyright©2001-2024 Bucaro TecHelp 13771 N Fountain Hills Blvd Suite 114-248 Fountain Hills, AZ 85268