HTML tables allow web developers to arrange data into rows and columns.
<table>
|
<thead>
|
<tr>
|
<th>
|
<tbody>
|
<td>
|
---|---|---|---|---|---|
The <table> tag is used to create a table in HTML, which is a block element that
represents tabular
data.
|
The <thead> tag in HTML is used to encapsulate a set of table rows
(<tr> elements) that
comprise the head of a table, typically containing column headers (<th> elements).
|
The <tr> tag is used to define a row in an HTML table. |
The <th> tag is used to designate a cell as a column header in a table. |
The <tbody> tag in HTML is used to define a set of rows that make up the body of an
HTML table. |
The <td> tag is used to define a data cell in an HTML table, and it is used as a child
element of
the <tr> element, which defines a table row. |
The table is made up of rows and columns of cells containing data. | This element provides semantic information about the table's structure and can be used for rendering on screens | It is an essential element in creating tables and is used in combination with the <th>
and
<td> tags to define table headers and data cells.
|
It is a part of the HTML and is used to define a header cell that can appear in the first row of an HTML table. | This tag is used inside the <table> tag and is a child of the
<table> tag.
|
The <td> tag can contain text, a form, an image, a table, etc. |
The text in <th> elements are bold and centered by default. |
The <tbody> tag is used to group the rows of a table together |
By default, the content inside it is positioned to the left. | |||
<colgroup> |
<col> |
span="" |
colspan="" |
<th> |
|
The <colgroup> element is
used to group one or more columns in a table for formatting. |
The <col> element represents a column within a <colgroup> . You can
use it to apply styles, such as width, background color, or other CSS properties, to entire columns. |
The span attribute defines the
number of columns a <col> or <colgroup> element should span. |
The colspan attribute defines
the number of columns a table cell should span. |
||
Its useful for applying styles to entire columns, instead of repeating the styles for each cell, for each row. | This represents the first column in the table. It has no additional attributes or classes, so any styling or attributes applied will be default or inherited. |
A table in HTML consists of table cells inside rows and columns.
The table element <table>
is used to create a table. The thead, tbody, and tfoot elements
are used to
define
the head, body, and footer sections of a table, respectively.
Within <head>
, we nest
<tr>
and
then
<th>
which apply an new row to each heading that we apply inbetween the
<th>
and </th>
tags.
Within <body>
, we nest <tr>
followed and then as many
<td>
s that we need within that
column.
justify-content The
justify-content property aligns items horizontally and accepts the following values:
|
|||||
flex-start: Items align to the left side of the container.the property aligns items
horizontally and accepts the following values:
|
flex-end : Items align to the right side of the container.
|
center : Items align at the center of the container. |
space-between : Items display with equal spacing between them. |
space-around : Items display with equal spacing around them. |
align-items This CSS property aligns items vertically and accepts the following values: |
flex-start : Items align to the top of the container.
|
flex-end : Items align to the bottom of the container. |
center: Items align at the vertical center of the container. |
baseline : Items display at the baseline of the container. |
stretch : Items are stretched to fit the container. |
flex-direction This CSS property defines the direction items are placed in the container, and accepts the following values: |
row : Items are placed the same as the text direction.
|
row-reverse : Items are placed opposite to the text direction. |
column : Items are placed top to bottom. |
column-reverse : Items are placed bottom to top. |
flex-direction This CSS property defines the direction items are placed in the container, and accepts the following values: |
|||||
row : Items are placed the same as the text direction.
|
row-reverse : Items are placed opposite to the text direction.
|
column : Items are placed top to bottom.
|
column-reverse : Items are placed bottom to top.
|
order The order property will reorder the elements according to the values given to the element and its order property.
|
|
By default, items have a value of 0, but we can use this property to also set it to a positive or negative integer value (-2, -1, 0, 1, 2). | When you assign an order value to a specific item, it will be positioned according to that value relative to the default 0 values of other items. | Positive Order Values: Items with higher order values will be placed further to the right (or bottom in a column layout). | Negative Order Values: Items with lower (negative) order values will be placed further to the left (or top in a column layout). |
align-self This is another property used tp target individual item/s. It accepts the same values, and acts as align-items
|
|
placeholder placeholder2 |
flex-wrap determines whether flex items are forced onto one line or can wrap onto multiple lines. It’s a useful property for designing responsive and flexible layouts. |
||||
nowrap : Every item is fit to a single line.
|
wrap : Items will wrap onto new lines if necessary.
|
wrap-reverse : Items will wrap onto new lines in reverse order if necessary.
|
Trust me, its easier than it sounds... |
flex-flow The two properties flex-direction and flex-wrap are used so often together that the shorthand property flex-flow was created to combine them. |
This shorthand property accepts the value of the two properties separated by a space. Ex:
flex-flow: row wrap
|
align-content use align-content to set how
multiple lines are spaced apart from each other. This property takes the following values:
|
flex-start : Lines are packed at the top of the container.
|
flex-end : Lines are packed at the bottom of the container.
|
center : Lines are packed at the vertical center of the container.
|
space-between : Lines display with equal spacing between them.
|
space-around : Lines are evenly distributed in the flex container's main axis, with equal
space around each line.
|
space-evenly : Lines are stretched to fit the container.
|
When you set the direction to row-reverse
or column-reverse
, flex-start
and flex-end
are also reversed.
when the flex-direction
is a column, justify-content
changes to the vertical and
align-items
to the horizontal.
Certainly! The transform: translate(-50%, -50%); property, used in conjunction with top and left, is a powerful way to center an element both horizontally and vertically within its containing block. Here’s how it works: Breakdown of transform: translate(-50%, -50%); translate(-50%, -50%): This part of the transform property moves the element by a percentage of its own dimensions: -50% on the x-axis moves the element left by 50% of its own width. -50% on the y-axis moves the element up by 50% of its own height. Relative to Element's Size: The translate function moves the element relative to its own size. So -50% translates to 50% of the element’s width (for the x-axis) or height (for the y-axis). How It Works with top and left When you use top: 50%; left: 50%; in combination with transform: translate(-50%, -50%);, here’s what happens: Positioning with top and left: top: 50%; left: 50%; positions the element’s top-left corner at the midpoint of its containing block (which is the parent element). Translation: After positioning the element’s top-left corner at 50% of the container’s width and height, transform: translate(-50%, -50%); moves the element back by 50% of its own width and height. This effectively centers the element's center point at the midpoint of its containing block. Example Assume you have a parent container of width 500px and height 300px, and you want to center a child element of width 200px and height 100px. Positioning: top: 50%; left: 50%; will place the top-left corner of the child 250px from the left and 150px from the top of the parent container (which is halfway through the parent container). Centering: transform: translate(-50%, -50%); will then move the child element up by 50px (half of 100px) and left by 100px (half of 200px), so the child’s center aligns with the center of the parent container.
top: 50%; left: 50%; positions the top-left corner of the element at the center of its parent container. transform: translate(-50%, -50%); shifts the element back by half of its own width and height, centering it horizontally and vertically. This combination is a common technique for perfectly centering elements in both dimensions within their containing block.
grid-template-rows defines the number and sizes of the rows of the grid grid-template is a shorthand for defining both grid-template-columns and grid-template-rows in one line row-gap puts blank space between the rows of the grid column-gap puts blank space between the columns of the grid gap is a shorthand for defining both row-gap and column-gap in one line grid-row-start and grid-row-end makes elements span certain rows of the grid grid-column-start and grid-column-end makes elements span certain columns of the grid grid-area is a shorthand for grid-row-start, grid-column-start, grid-row-end, and grid-column-end, all in one line
.container { width: 50%; height: 200px; overflow: hidden; } .container img { max-width: 100%; height: auto; display: block; }
In the example above, .container represents a container div. It is set to a width of 50% (half of the browser’s width, in this example) and a height of 200 pixels. Setting overflow to hidden ensures that any content with dimensions larger than the container will be hidden from view. The second CSS rule ensures that images scale with the width of the container. The height property is set to auto, meaning an image’s height will automatically scale proportionally with the width. Finally, the last line will display images as block level elements (rather than inline-block, their default state). This will prevent images from attempting to align with other content on the page (like text), which can add unintended margin to the images. It’s worth memorizing the entire example above. It represents a very common design pattern used to scale images and videos proportionally.