---
title: Contains Element Test
description: "The elements presented in the content panel are quite flat, but there is a certain amount of nesting possible. For example, a *span* element may appear within a paragraph element or nested within another *span* element. Sometimes, this nesting is…"
url: "https://www.stilo.com/docs/migrate/types-of-tests-used-in-rules/contains-element-test/"
updated: "2021-04-25"
category: Rules / Types of Tests Used in Rules
tags:
  - Rules
---

# Contains Element Test

The elements presented in the content panel are quite flat, but there is a certain amount of nesting possible. For example, a *span* element may appear within a paragraph element or nested within another *span* element. Sometimes, this nesting is significant in correctly identifying content to convert.

The contains element test allows for a nested element to be tested. Thus, your rule can test outer and nested elements in combination. As well, your rule can place annotations on either the outer element or the nested elements. Be default, annotations are placed on the outer elements, but you can provide a label for the nested element, and place the annotation *on* them explicitly.

*Example: contains element test*

The following rule attempts to identify content that should be tagged as uicontrol. It is not enough for the term to be bold in the input document. However, bold text found in a paragraph styled as Step is determined to reliably identify a uicontrol.

[![contains element test](https://www.stilo.com/wp-content/uploads/2021/03/contains-element-test.png)](https://www.stilo.com/wp-content/uploads/2021/03/contains-element-test.png)

*Example: annotating both the inner and outer elements*

The following applies an annotation to the paragraph as well as the nested *span*.

We want the paragraph to be annotated as a step regardless of whether or not there happen to be any uicontrols. So we need to make sure that the entire test does not fail because the contains element test fails. That is, we don't really care whether the contains element test evalutes to true or false. That's why we have placed the contains element test under a logical or-group that include the literal true. This is a common idiom that you may find useful in your rules.

#### Prerequisite Concepts

- [Edit Mode](https://www.stilo.com/docs/migrate/getting-started-rules/edit-mode/)
- [Rule Conditions](https://www.stilo.com/docs/migrate/getting-started-rules/rule-conditions/)

#### Supporting Reference Material

- [Style Test](https://www.stilo.com/docs/migrate/types-of-tests-used-in-rules/style-test/)
- [Property Test](https://www.stilo.com/docs/migrate/types-of-tests-used-in-rules/property-test/)
- [Logical Group Test](https://www.stilo.com/docs/migrate/types-of-tests-used-in-rules/logical-group-test/)
- [Content Test](https://www.stilo.com/docs/migrate/types-of-tests-used-in-rules/content-test/)
- [Context Test](https://www.stilo.com/docs/migrate/types-of-tests-used-in-rules/context-test/)
- [Patterns](https://www.stilo.com/docs/migrate/types-of-tests-used-in-rules/patterns/)
- [On](https://www.stilo.com/docs/migrate/types-of-tests-used-in-rules/on/)

#### Related Tasks

- [Deleting a Rule](https://www.stilo.com/docs/migrate/editing-rules/deleting-a-rule/)
- [Turning a rule on or off](https://www.stilo.com/docs/migrate/editing-rules/turning-a-rule-on-or-off/)
- [Commenting a rule](https://www.stilo.com/docs/migrate/editing-rules/commenting-a-rule/)
- [Adding a Test in a Condition](https://www.stilo.com/docs/migrate/editing-rules/adding-a-test-in-a-condition/)
- [Deleting a Test From a Condition](https://www.stilo.com/docs/migrate/editing-rules/deleting-a-test-from-a-condition/)
- [Moving a Test in a Condition](https://www.stilo.com/docs/migrate/editing-rules/moving-a-test-in-a-condition/)
- [Adding an Annotation](https://www.stilo.com/docs/migrate/editing-rules/adding-an-annotation/)
- [Deleting an Annotation](https://www.stilo.com/docs/migrate/editing-rules/deleting-an-annotation/)
- [Moving an Annotation](https://www.stilo.com/docs/migrate/editing-rules/moving-an-annotation/)
