HTML
HTML
The link text is the part that will be visible to the reader.
A table in HTML
consists of table cells
inside rows and
columns.
HTML Tables - Syntax
Table Cells
Each table cell is defined by a <td> and a
</td> tag.
td stands for table data.
Everything between <td> and </td> are the
content of the table cell.
Note: A table cell can contain all sorts of
HTML elements: text, images, lists, links, other
tables, etc.
Table Rows
Each table row starts with a <tr> and ends with
a </tr> tag.
tr stands for table row.
You can have as many rows as you like in a
table; just make sure that the number of cells
are the same in each row.
Note: There are times when a row can have less
or more cells than another. You will learn about
that in a later chapter.
Table Headers
Sometimes you want your cells to be table
header cells. In those cases use the <th> tag
instead of the <td> tag:
th stands for table header.
HTML Lists
HTML lists allow web developers to group a set
of related items in lists.
Unordered HTML List
An unordered list starts with the <ul> tag. Each
list item starts with the <li> tag.
The list items will be marked with bullets (small
black circles) by default:
Ordered HTML List
An ordered list starts with the <ol> tag. Each list
item starts with the <li> tag.
The list items will be marked with numbers by
default:
HTML Description Lists
HTML also supports description lists.
A description list is a list of terms, with a
description of each term.
The <dl> tag defines the description list, the
<dt> tag defines the term (name), and the
<dd> tag describes each term:
HTML Description Lists
HTML also supports description lists.
A description list is a list of terms, with a
description of each term.
The <dl> tag defines the description list, the
<dt> tag defines the term (name), and the
<dd> tag describes each term:
Block-level Elements
A block-level element always starts on a new line,
and the browsers automatically add some space (a
margin) before and after the element.
A block-level element always takes up the full width
available (stretches out to the left and right as far as
it can).
Two commonly used block elements are: <p> and
<div>.
The <p> element defines a paragraph in an HTML
document.
The <div> element defines a division or a section in
an HTML document.
Block-level Elements
Inline Elements
HTML Div Element
The <div> element is used as a
container for other HTML elements.
The <div> element is by default a
block element, meaning that it takes
all available width, and comes with
line breaks before and after.
The <div> element has no required
attributes, but style, class and id are
common.
HTML Div Element
<div> as a container
he <div> element is often used to group
sections of a web page together.
Multiple <div> elements
If you have a <div> element that is not 100%
wide, and you want to center-align it, set
the CSS margin property to auto.
Multiple <div> elements
Multiple <div> elements
Center align a <div> element
If you have a <div> element that is not 100%
wide, and you want to center-align it, set
the CSS margin property to auto.
Center align a <div> element
If you have a <div> element that is not 100%
wide, and you want to center-align it, set
the CSS margin property to auto.
Aligning <div> elements side by side
When building web pages, you often want to have two or more
<div> elements side by side, like this:
Float
The CSS float property was not
originally meant to align <div>
elements side-by-side, but has been
used for this purpose for many years.
The CSS float property is used for
positioning and formatting content
and allows elements to be positioned
horizontally, rather than vertically.
Float
Float
Inline-block
If you change the <div> element's display property
from block to inline-block, the <div> elements will no
longer add a line break before and after, and will be
displayed side by side instead of on top of each
other.
Inline-block
If you change the <div> element's display property
from block to inline-block, the <div> elements will no
longer add a line break before and after, and will be
displayed side by side instead of on top of each
other.
Flex
The CSS Flexbox Layout Module was introduced to
make it easier to design flexible responsive layout
structure without using float or positioning.
To make the CSS flex method work, surround the
<div> elements with another <div> element and give it
the status as a flex container.
Flex
The CSS Flexbox Layout Module was introduced to
make it easier to design flexible responsive layout
structure without using float or positioning.
To make the CSS flex method work, surround the
<div> elements with another <div> element and give it
the status as a flex container.
Grid
The CSS Grid Layout Module offers a grid-based
layout system, with rows and columns, making it
easier to design web pages without having to use
floats and positioning.
Sounds almost the same as flex, but has the ability to
define more than one row and position each row
individually.
The CSS grid method requires that you surround the
<div> elements with another <div> element and give
the status as a grid container, and you must specify
the width of each column.
Grid
HTML class Attribute
The class attribute is often used to point to a
class name in a style sheet. It can also be
used by a JavaScript to access and
manipulate elements with the specific class
name.