diff --git a/site/content/tutorial/13-advanced-styling/03-inline-styles/app-b/App.svelte b/site/content/tutorial/13-advanced-styling/03-inline-styles/app-b/App.svelte index 6bda27021b..58280f71ad 100644 --- a/site/content/tutorial/13-advanced-styling/03-inline-styles/app-b/App.svelte +++ b/site/content/tutorial/13-advanced-styling/03-inline-styles/app-b/App.svelte @@ -5,7 +5,7 @@ -

This is a paragraph.

+

This is a paragraph.

diff --git a/site/content/tutorial/13-advanced-styling/03-style-directive/app-b/App.svelte b/site/content/tutorial/13-advanced-styling/03-style-directive/app-b/App.svelte new file mode 100644 index 0000000000..aade861b43 --- /dev/null +++ b/site/content/tutorial/13-advanced-styling/03-style-directive/app-b/App.svelte @@ -0,0 +1,15 @@ + + + + +

This is a paragraph.

+ + diff --git a/site/content/tutorial/13-advanced-styling/03-style-directive/text.md b/site/content/tutorial/13-advanced-styling/03-style-directive/text.md new file mode 100644 index 0000000000..34fa9881a1 --- /dev/null +++ b/site/content/tutorial/13-advanced-styling/03-style-directive/text.md @@ -0,0 +1,16 @@ +--- +title: Inline styles and the style directive +--- + +Being able to set css properties dynamically is nice, however this can get unwieldly if you have to write a long string, and mistakes like missing any of the semicolons could make the whole string invalid. Therefore, Svelte provides a nicer way to write inline styles with the style directive. + +Change the style attribute of the paragraph to the following: + +```html +

+``` + +Style directives share a few qualities with class directives. You can use a shorthand when the name of the property and the variable are the same. So `style:color="{color}"` can be written as just `style:color`. And just like class directives, the directives will take precedence if you set the same property through a style attribute.