--- title: Nested components --- As well as containing elements (and `if` blocks and `each` blocks), Svelte components can contain *other* Svelte components. ```html
``` ```html

I am a nested component. The answer is {answer}

``` That's similar to doing this... ```js import Widget from './Widget.html'; const widget = new Widget({ target: document.querySelector('.widget-container'), props: { answer: 42 } }); ``` ...except that Svelte takes care of destroying the child component when the parent is destroyed, and keeps props in sync if they change. > Component names must be capitalised, following the widely-used JavaScript convention of capitalising constructor names. It's also an easy way to distinguish components from elements in your template. ### Props Props, short for 'properties', are the means by which you pass data down from a parent to a child component — in other words, they're just like attributes on an element. As with element attributes, prop values can contain any valid JavaScript expression. Often, the name of the property will be the same as the value, in which case we can use a shorthand: ```html ``` > Note that props are *one-way* — to get data from a child component into a parent component, use [bindings](guide#bindings). ### Composing with `` A component can contain a `` element, which allows the parent component to inject content: ```html

Hello!

This is a box. It can contain anything.

``` ```html
``` The `` element can contain 'fallback content', which will be used if no children are provided for the component: ```html ``` ```html

the box is empty!

``` You can also have *named* slots. Any elements with a corresponding `slot` attribute will fill these slots: ```html P. Sherman 42 Wallaby Way, Sydney ``` ```html

Unknown address
Unknown email
```