0% found this document useful (0 votes)
13 views5 pages

HTML Table Basics and Examples

The document discusses HTML tables and defines the various tags used to define tables, rows, and cells. It provides examples of code to create a basic table with rows and cells, add borders, and define header rows using <th> tags. It also includes a table listing the main HTML table tags and their descriptions.

Uploaded by

Tina Chavez
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views5 pages

HTML Table Basics and Examples

The document discusses HTML tables and defines the various tags used to define tables, rows, and cells. It provides examples of code to create a basic table with rows and cells, add borders, and define header rows using <th> tags. It also includes a table listing the main HTML table tags and their descriptions.

Uploaded by

Tina Chavez
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd

HTML Tables

Tables are defined with the <table> tag.

A table is divided into rows (with the <tr> tag), and each row is divided into data cells (with the <td>
tag). td stands for "table data," and holds the content of a data cell. A <td> tag can contain text,
links, images, lists, forms, other tables, etc.

Table Example

<table border="1">
<tr>
<td>row 1, cell 1</td>
<td>row 1, cell 2</td>
</tr>
<tr>
<td>row 2, cell 1</td>
<td>row 2, cell 2</td>
</tr>
</table>

HTML Tables
Apples 44%
Bananas 23%
Oranges 13%
Other 10%

HTML Tables and the Border Attribute


If you do not specify a border attribute, the table will be displayed without borders. Sometimes this
can be useful, but most of the time, we want the borders to show.

To display a table with borders, specify the border attribute:

<table border="1">
<tr>
<td>Row 1, cell 1</td>
<td>Row 1, cell 2</td>
</tr>
</table>

HTML Table Headers


Header information in a table are defined with the <th> tag.

All major browsers will display the text in the <th> element as bold and centered.
<table border="1">
<tr>
<th>Header 1</th>
<th>Header 2</th>
</tr>
<tr>
<td>row 1, cell 1</td>
<td>row 1, cell 2</td>
</tr>
<tr>
<td>row 2, cell 1</td>
<td>row 2, cell 2</td>
</tr>
</table>

How the HTML code above looks in your browser:

Header 1 Header 2
row 1, cell 1 row 1, cell 2
row 2, cell 1 row 2, cell 2

HTML Table Tags

Tag Description
<table> Defines a table
<th> Defines a table header
<tr> Defines a table row
<td> Defines a table cell
<caption> Defines a table caption
<colgroup> Defines a group of columns in a table, for formatting
<col /> Defines attribute values for one or more columns in a table
<thead> Groups the header content in a table
<tbody> Groups the body content in a table
<tfoot> Groups the footer content in a table
HTML Lists

An ordered list: An unordered list:


1. The first list item  List item
2. The second list item  List item

3. The third list item  List item

HTML Unordered Lists


An unordered list starts with the <ul> tag. Each list item starts with the <li> tag.

The list items are marked with bullets (typically small black circles).

<ul>
<li>Coffee</li>
<li>Milk</li>
</ul>

How the HTML code above looks in a browser:

 Coffee
 Milk

HTML Ordered Lists


An ordered list starts with the <ol> tag. Each list item starts with the <li> tag.

The list items are marked with numbers.

<ol>
<li>Coffee</li>
<li>Milk</li>
</ol>

How the HTML code above looks in a browser:

1. Coffee
2. Milk

HTML Definition Lists


A definition list is a list of items, with a description of each item.

The <dl> tag defines a definition list.

The <dl> tag is used in conjunction with <dt> (defines the item in the list) and <dd> (describes the item
in the list):

<dl>
<dt>Coffee</dt>
<dd>- black hot drink</dd>
<dt>Milk</dt>
<dd>- white cold drink</dd>
</dl>

How the HTML code above looks in a browser:

Coffee
- black hot drink
Milk
- white cold drink

HTML List Tags

Tag Description
<ol> Defines an ordered list
<ul> Defines an unordered list
<li> Defines a list item
<dl> Defines a definition list
<dt> Defines an item in a definition list
<dd> Defines a description of an item in a definition list

/* _______________ Text _____ */


body {
font-family: Lucida Grande;
font-size: 11px;
color: #333333;
font-weight: normal;
font-style: normal;
text-align:justify;
text-decoration: none;
text-transform: none;
letter-spacing: auto;
line-height: auto;
word-wrap: break-word;
-webkit-text-stroke: 1px transparent;
overflow-x: hidden;
}

a:link, a:active, a:visited {


color: #66ac95;
text-decoration: none;
-o-transition: color 2s linear;
-webkit-transition: color 2s linear;
-moz-transition: color 2s linear;
}

Font Properties
Property Description CSS
font Sets all the font properties in one declaration 1
font-family Specifies the font family for text 1
font-size Specifies the font size of text 1
font-style Specifies the font style for text 1
font-variant Specifies whether or not a text should be displayed in a small-caps 1
font
font-weight Specifies the weight of a font

Common questions

Powered by AI

Unordered lists (<ul>) are effective in web design for organizing content when hierarchy is irrelevant and visual grouping of items is desired. They provide a clean, accessible way to list non-sequential items like features, benefits, or any items that need to be shown together without implying a particular order. This format enhances readability and the visual structure of the content, accommodating various design aesthetics .

The <ol> tag in HTML creates an ordered list where the items are presented with a numerical prefix indicating their order, while the <ul> tag creates an unordered list where items are preceded by bullet points. This difference impacts content presentation by allowing for both structured hierarchy in ordered lists and visual grouping without hierarchy in unordered lists .

The <caption> tag provides a brief, descriptive title for an HTML table, enhancing table accessibility and clarification of the table's content. This tag appears at the top of the table and helps visually impaired users, who utilize screen readers, to comprehend the purpose and scope of the table more clearly .

The CSS property font-family determines the typeface used in the text, which directly impacts readability and aesthetic appeal. By specifying the font-family, designers can choose fonts that are more readable at various sizes and provide visual coherence with the overall design, enhancing user experience and text legibility .

CSS enhances the visual presentation of HTML links by allowing customization of color, text decoration, and transitions, among other properties. Specifically, the CSS property -webkit-transition (as well as -o- and -moz- transitions for cross-browser compatibility) is used to create smooth transitions in link color changes, improving the user experience by providing visual feedback related to link interaction states .

The border attribute influences the presentation of HTML tables by outlining cells, which makes the table more visually distinct and easier to read. When the border attribute is omitted, the table displays without borders, which might obscure the delineation between cells, potentially complicating data interpretation. Including the attribute enhances both clarity and aesthetics of the table .

The CSS property font-style defines the style of the font in terms of italics or normal, which serves both functional and stylistic purposes. It is particularly effective in scenarios where emphasis or differentiation of text is required, such as in citations, quotes, or stylistic contrasts between different text elements .

The <tbody>, <thead>, and <tfoot> tags in HTML tables provide structural and organizational benefits by segmenting table data into different sections - header, body, and footer. This not only enhances semantic organization but also improves accessibility as screen readers can better navigate these segments. Additionally, they allow for easier styling and manipulation of specific parts of a table, aiding developers in maintaining clear and structured code .

The <th> elements are important in tables as they define header cells, which most browsers render as bold and centered. They contribute significantly to user experience by clearly distinguishing header information from table data, which aids both comprehension and navigation. Accessibility is enhanced as screen readers identify these headers and support users in associating column or row headers with their data cells, facilitating better interaction for visually impaired users .

The <dt> and <dd> tags enhance semantics and accessibility by clearly associating descriptions with their terms in definition lists. They ensure that screen readers convey content as defined terms and their descriptions, improving comprehension for users with disabilities. Semantics are improved by explicitly defining the relationship between terms and definitions, aiding both human and machine readability .

You might also like