CSS: Block height and width
When you create pages, you often want to control the height and width of blocks. This is useful in long articles when you want to put explanatory text in a small block. This way it will be separated from the main part of the text, and you can see it immediately.
The rules width and height are used to control the height and width of block elements, taking values for width and height respectively (in pixels or other available units of measure, for example).
Let's create a block 100 pixels high and 100 pixels wide. To visually separate it from the theory in the tutorial, set the background color to black:
<style>
.square {
width: 100px;
height: 100px;
background-color: #000;
}
</style>
<div class="square"></div>
Instructions
Add <div> to the editor with the class set to rectangle. Set the properties:
- Width: 300px
- Height: 100px
- Background color:
#000.
Write the styles in the <style> tag
If you've reached a deadlock it's time to ask your question in the «Discussions». How ask a question correctly:
- Be sure to attach the test output, without it it's almost impossible to figure out what went wrong, even if you show your code. It's complicated for developers to execute code in their heads, but having a mistake before their eyes most probably will be helpful.
CSS: Block height and width
When you create pages, you often want to control the height and width of blocks. This is useful in long articles when you want to put explanatory text in a small block. This way it will be separated from the main part of the text, and you can see it immediately.
The rules width and height are used to control the height and width of block elements, taking values for width and height respectively (in pixels or other available units of measure, for example).
Let's create a block 100 pixels high and 100 pixels wide. To visually separate it from the theory in the tutorial, set the background color to black:
<style>
.square {
width: 100px;
height: 100px;
background-color: #000;
}
</style>
<div class="square"></div>
Instructions
Add <div> to the editor with the class set to rectangle. Set the properties:
- Width: 300px
- Height: 100px
- Background color:
#000.
Write the styles in the <style> tag
If you've reached a deadlock it's time to ask your question in the «Discussions». How ask a question correctly:
- Be sure to attach the test output, without it it's almost impossible to figure out what went wrong, even if you show your code. It's complicated for developers to execute code in their heads, but having a mistake before their eyes most probably will be helpful.
Your exercise will be checked with these tests:
const { test } = require('tests');
test(({ query, expect }) => {
const element = query(document, '.rectangle');
const style = getComputedStyle(element);
expect(style).to.have.property('width', '300px');
expect(style).to.have.property('height', '100px');
expect(style).to.have.property('background-color', 'rgb(0, 0, 0)');
});Teacher's solution will be available in:
20:00
