This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
web_design:horario:margins_padding [2021/10/11 09:03] mag created |
web_design:horario:margins_padding [2023/08/16 09:33] (current) |
||
---|---|---|---|
Line 1: | Line 1: | ||
====== Web Development Lesson 3 - Tablas ====== | ====== Web Development Lesson 3 - Tablas ====== | ||
- | ===== Margins and Padding ===== | + | ===== Padding |
+ | ==== Objective ==== | ||
+ | In this activity we'll adjust the spacing between cells and within cells to make it more readable. We'll also look at various display options used to position elements in relation to each other. | ||
==== Setup ==== | ==== Setup ==== | ||
+ | * Continue using your [[https:// | ||
+ | **HTML** | ||
+ | < | ||
+ | < | ||
+ | <tr> | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | </tr> | ||
+ | </ | ||
+ | < | ||
+ | <tr> | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | </tr> | ||
+ | <tr> | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | </tr> | ||
+ | <tr> | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | </tr> | ||
+ | <tr> | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | </tr> | ||
+ | </ | ||
+ | </ | ||
+ | **CSS** | ||
+ | < | ||
+ | border-width: | ||
+ | border-style: | ||
+ | }</ | ||
+ | |||
+ | ==== Padding ==== | ||
+ | * Padding is the space between the element (in this case the text) and the border. | ||
+ | * Let's add 10 pixels around each side of the text in data cells. | ||
+ | * Because we only want to apply the padding to the data cells and not the header cells, we have to create a new target in the CSS code. | ||
+ | < | ||
+ | padding-left: | ||
+ | padding-right: | ||
+ | padding-top: | ||
+ | padding-bottom: | ||
+ | }</ | ||
+ | |||
+ | ==== Collapsing Borders ==== | ||
+ | * Personally, I don't like the space between the table cells, so I like to remove it. | ||
+ | * Apply the < | ||
+ | < | ||
+ | border-collapse: | ||
+ | }</ | ||
+ | |||
+ | ==== Block vs Inline ==== | ||
+ | * Every element in HTML is either block or inline, which affects how it and the elements around it appear on the page. | ||
+ | * < | ||
+ | * < | ||
+ | * Let's look at the difference. By default, table cells are inline elements (they are arranged side by side), but we can force them to be block elements using the following code in the td target. | ||
+ | < | ||
+ | * What happens when you run the code? Do all the table cells stack on top of each other? | ||
+ | * There is another option you can use. Try changing < | ||
+ | < | ||
+ | * What happened? The data cells should disappear. | ||
+ | * This option isn't much use on its own as noone would ever see the content. It's only useful when using Javascript to change an element' | ||
+ | * To restore the table, remove the code < | ||
+ | |||
+ | [[web_design: |