---
title: "css greater than sign"  
description: "Greater than sign used for apply CSS on HTML element in optimized way."  
author: "AVADHESH PATEL"  
published: 2013-04-25  
updated: 2019-09-07  
canonical: https://www.mindstick.com/articles/1267/css-greater-than-sign  
category: "css-css3"  
tags: ["css-css3"]  
reading_time: 2 minutes  

---

# css greater than sign

Greater than sign used for [apply](https://www.mindstick.com/articles/13148/discover-to-apply-make-up-like-a-professional-supermodel) CSS on HTML element in optimized way.

##### With element

##### Syntax:

```
element > element
```

##### Example

```
div > p
```

Apply on all <p> [elements](https://www.mindstick.com/forum/1440/wpf-button-with-multiple-text-elements) where the parent is a <div> element.

##### With class

##### Syntax

```
class > element
```

##### Example

```
.a  >  div
```

Apply on all <div> elements where the parent is a <div> with a [class](https://www.mindstick.com/blog/165/generic-class-in-c-sharp) (.a).

##### With id

##### Syntax

```
id > element
```

##### Example

```
#a  >  div
```

Apply on all <div> elements where the parent is a <div> with an id (#a).

##### For example

```
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head runat="server">    <title></title>    <style type="text/css">        .bg>div {            background-color: #E5E5E5;        }         div>p {            color: #600000;        }    </style></head><body>    <form id="form1" runat="server">        <div id="idred" class='bg' style="height: 150px; border: 2px solid #ff0000;">            <div id="idgreen" style="height: 60px; border: 2px solid #00ff00;">                <p>Greater Than sign (>) CSS Selector demo</p>            </div>            <br />            <div id="idblue" style="height: 60px; border: 2px solid #0000ff;">                <p>Greater Than sign (>) CSS Selector demo</p>            </div>        </div>    </form></body></html>
```

Note: If you do not include or change “[doctype](https://www.mindstick.com/interview/23388/what-is-the-importance-of-the-html-doctype)” than it not supported by lower [version](https://www.mindstick.com/articles/12845/things-to-remember-while-migrating-odoo-to-a-better-version) of IE (IE 8, IE 7 and IE 6).\

##### See Figure:

![css greater than sign](https://www.mindstick.com/mindstickarticle/d0e73514-fecf-45f8-b466-755c69286e51/images/ba5c5305-2970-4387-ab8d-3bf106011dba.png)

From the above figure, you can see "bg" class applyed on "idgreen","idblue" div not on "idred" div, and which <p> element inside on div on that CSS are applied.

---

Original Source: https://www.mindstick.com/articles/1267/css-greater-than-sign

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
