# Inheritance in CSS

**URL:** https://forum.kirupa.com/t/inheritance-in-css/186420
**Category:** web dev
**Created:** [April 21, 2006, 3:34am UTC](https://forum.kirupa.com/t/inheritance-in-css/186420 "2006-04-21T03:34:46Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![silverType](https://avatars.discourse-cdn.com/v4/letter/s/ac91a4/32.png) [@silverType](https://forum.kirupa.com/u/silverType)
#### Post date: [April 21, 2006, 3:34am UTC](https://forum.kirupa.com/t/inheritance-in-css/186420/1 "2006-04-21T03:34:46Z")

</div>

Hi guys,  
I’ve defined a class for my textboxes in CSS called .textbox and gave it the following properties:

.textbox {  
font-family: Verdana, Arial, Helvetica, sans-serif;  
color: #CCCCCC;  
margin: 15px 0 0 10px;  
padding: 2px;  
font-size: 9px;  
height: 22px;  
width:207px;  
}

Now, let’s say if I want to create another textbox of a different width and height, say height:30px, width:110px. How should I define its class such that it still inherits the other properties from textbox? Thanks in advance.

---

<div class="post-metadata">

### Author: ![Ankou](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/ankou/32/1351_2.png) [@Ankou](https://forum.kirupa.com/u/Ankou)
#### Post date: [April 21, 2006, 4:23am UTC](https://forum.kirupa.com/t/inheritance-in-css/186420/2 "2006-04-21T04:23:04Z")

</div>

Depending on how you set up and planned your site, you could do:

```auto
.textbox, .othertextbox {
font-family: Verdana, Arial, Helvetica, sans-serif;
color: #CCCCCC;
margin: 15px 0 0 10px;
padding: 2px;
font-size: 9px;
}

.textbox { height: 22px; width:207px; }
.othertextbox{ height: 50px; width: 300px; }

```

---

<div class="post-metadata">

### Author: ![bwh2](https://avatars.discourse-cdn.com/v4/letter/b/8c91f0/32.png) [@bwh2](https://forum.kirupa.com/u/bwh2)
#### Post date: [April 21, 2006, 4:27am UTC](https://forum.kirupa.com/t/inheritance-in-css/186420/3 "2006-04-21T04:27:10Z")

</div>

```auto

.textbox,.textbox2 { 
             font-family: Verdana, Arial, Helvetica, sans-serif;
	color: #CCCCCC;
	margin: 15px 0 0 10px;
	padding: 2px;
	font-size: 9px;
        height: 22px;
	width:207px;
}
.textbox2 { 
        my own properties...
}

```

---

<div class="post-metadata">

### Author: ![silverType](https://avatars.discourse-cdn.com/v4/letter/s/ac91a4/32.png) [@silverType](https://forum.kirupa.com/u/silverType)
#### Post date: [April 21, 2006, 7:48am UTC](https://forum.kirupa.com/t/inheritance-in-css/186420/4 "2006-04-21T07:48:47Z")

</div>

> [@Ankou](#):
>
> Depending on how you set up and planned your site, you could do:
> 
> ```auto
> .textbox, .othertextbox {
> font-family: Verdana, Arial, Helvetica, sans-serif;
> color: #CCCCCC;
> margin: 15px 0 0 10px;
> padding: 2px;
> font-size: 9px;
> }
> 
> .textbox { height: 22px; width:207px; }
> .othertextbox{ height: 50px; width: 300px; }
> 
> ```

I see. Thanks. Will try tat out. Btw, I’ve learnt about another method from this site: [Can a CSS class inherit properties from another CSS class? - HTML / CSS](http://www.thescripts.com/forum/thread459731.html). Thought you might be interested.

---

<div class="post-metadata">

### Author: ![Ankou](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/ankou/32/1351_2.png) [@Ankou](https://forum.kirupa.com/u/Ankou)
#### Post date: [April 21, 2006, 6:33pm UTC](https://forum.kirupa.com/t/inheritance-in-css/186420/5 "2006-04-21T18:33:51Z")

</div>

Yeah I use that one as well, it doesn’t matter which method you do really. The method you linked to I typically only use when working with simple CSS rulesets.

Otherwise I’ve found that when I’m working with a class that has a lot of rules in it that it’s easier to mess up. Not to mention usually a lot of rules for a class means it’s a heavily styled element – which would typically mean down the road I plan to change it if I do a site redesign. Which could lead to needing to edit some HTML code. Which kind of defeats one of my main reasons for lovin’ CSS so much. 🙂
