Lesson 5_ HTML Structure and Content Organization Part 2
Lesson 5_ HTML Structure and Content Organization Part 2
● The page title describes the content and meaning of the page.
● Defined using the <title> element inside the <head> section.
HTML Page Title
The title is shown in the browser's title bar:
HTML Tables
HTML tables allow web developers to arrange data into rows and
columns.
HTML Tables
Define an HTML Table
● To add a border, use the CSS border property on table, th, and td
elements:
HTML Table Borders
Collapsed Table Borders
● To avoid having double borders like in the example above, set the
CSS border-collapse property to collapse.
● This will make the borders collapse into a single border:
HTML Table Borders
Style Table Borders
● If you set a background color of each cell, and give the border a
white color (the same as the document background), you get the
impression of an invisible border:
HTML Table Borders
Round Table Borders
Skip the border around the table by leaving out table from the css
selector:
HTML Table Borders
Dotted Table Borders
● With the border-style property, you can set the appearance of the
border.
HTML Table Borders
Dotted Table Borders
With the border-color property, you can set the color of the border.
HTML Table Sizes
● HTML tables can have different sizes for each column, row or the
entire table.
● Use the style attribute with the width or height properties to specify
the size of a table, row or column.
HTML Table Sizes
HTML Table Width
● To set the height of a specific row, add the style attribute on a table
row element:
HTML Table Sizes
HTML Table Row Height
Example
● Cell padding is the space between the cell edges and the cell
content.
● By default the padding is set to 0.
● To add padding on table cells, use the CSS padding property:
HTML Table Padding & Spacing
HTML Table - Cell Spacing
● If you add a background color on every other table row, you will get a
nice zebra stripes effect.
● To style every other table row element, use the :nth-child(even)
selector like this:
HTML Table Styling
HTML Table - Vertical Zebra Stripes
● You can combine the styling from the two examples above and you
will have stripes on every other row and every other column.
● If you use a transparent color you will get an overlapping effect.
● Use an rgba() color to specify the transparency of the color:
HTML Table Styling
Combine Vertical and Horizontal Zebra Stripes
HTML Table Styling
Horizontal Dividers
● If you specify borders only at the bottom of each table row, you will
have a table with horizontal dividers.
● Add the border-bottom property to all tr elements to get horizontal
dividers:
HTML Table Styling
Hoverable Table
● If you want to style the first two columns of a table, use the
<colgroup> and <col> elements.
● The <colgroup> element should be used as a container for the
column specifications.
● Each group is specified with a <col> element.
● The span attribute specifies how many columns get the style.
● The style attribute specifies the style to give the columns.
HTML Table Colgroup
HTML Table Colgroup
HTML Table Colgroup
Multiple Col Elements
● If you want to style multiple columns with different styles, use more
than one <col> element inside the <colgroup>:
HTML Table Colgroup
Empty Colgroups
Circle
HTML Unordered Lists
Square
No List Marker
HTML Unordered Lists
Nested HTML Lists
The type attribute of the <ol> tag, defines the type of the list item marker:
HTML Ordered Lists
Numbers
Uppercase Letters
HTML Ordered Lists
Lowercase Letters
By default, an ordered list will start counting from 1. If you want to start
counting from a specified number, you can use the start attribute:
HTML Ordered Lists
Nested HTML Lists
When building web pages, you often want to have two or more <div>
elements side by side, like this:
HTML Div Element
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.
HTML Div Element
Float
HTML Div Element
Float
HTML Div Element
Inline-block
● 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.
HTML Div Element
Grid
HTML Div Element
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.
● In the following example we have three <div> elements with a class
attribute with the value of "city". All of the three <div> elements will
be styled equally according to the .city style definition in the head
section:
HTML class Attribute
HTML class Attribute
Use of the class Attribute in JavaScript
Syntax
HTML Iframes
Iframe - Remove the Border
With CSS, you can also change the size, style and color of the iframe's
border:
HTML Iframes
Iframe - Set Height and Width
● Use the height and width attributes to specify the size of the iframe.
● The height and width are specified in pixels by default:
Or you can add the style attribute and use the CSS height and width
properties:
HTML Iframes
Iframe - Target for a Link