CSS Table Styling. Up to this point, as we haven't applied any CSS styling to our tables, our example tables have not been too pleasing to the eye. CSS.

Slides:



Advertisements
Similar presentations
LIS650 lecture 4 Thomas Krichel today CSS Properties –Box properties-- List properties –Table properties-- Classification properties –(Audio.
Advertisements

Working with Web Tables
CSS. Intro to CSS Cascading Style Sheets – styles and enhances appearance of webpage.css extension.
Client-Side Internet and Web Programming
Cascading Style Sheets Color and Background Controls Border and Margin Controls (Boxes)
9-May-15 More CSS. 2 A different emphasis CSS is the same for XML as it is for HTML and XHTML, but-- XML contains no display information If you want your.
Week 9 Using the Box Properties. 9-2 The CSS Visual Formatting Model Describes how the element content boxes should be displayed by the browser –Based.
CSS provides a way to stray away from the traditional methods of using tables to lay out pages. Success with this technique depends on understanding of.
Tutorial 4: Creating page layout with css
Tutorial 5 Working with the Box Model. XP Objectives Understand the box model Create padding, margins, and borders Wrap text around an image Float a block-level.
CSS: Class 1 Background Images, Controlling Position of Background Images, Add Padding to Page Elements, Add Borders to Elements on a Page.
CSS. What does it stand for? Cascading Style Sheets.
1 Lesson Style Sheets Box Model Content (text,image,table) Margin Padding Border Box.
Creating Tables Text Tables -created by using preformatted tags. Graphical Tables - created using Table Structure with HTML.
14-Jul-15 CSS Applications to XML. 2 A different emphasis CSS is the same for XML as it is for HTML, but-- HTML already does a pretty good job of layout.
1 CS428 Web Engineering Lecture 10 Images, Tables, Forms, Border-Radius (CSS – V)
CSS Box Model. What is the CSS Box Model? The “Box Model” is a tool we use to lay out our web pages in a number of individual "boxes" or "containers".
CSS Dvijesh Bhatt.
Dreamweaver -- CSS. Dreamweaver -- MX New icons are added in MX Most of the features commonly used in web design, and are same as FrontPage. New feature.
Principles of Web Design 6 th Edition Chapter 10 – Data Tables.
The Missing Manual MARGINS, PADDING, & BORDERS—CHAPTER 7.
CSS The Definitive Guide Chapter 8.  Allows one to define borders for  paragraphs  headings  divs  anchors  images  and more.
CHAPTER 10 Formatting Tables and Forms. Using Tables the Right Way  HTML and XHTML have a LOT of tags dedicated to building a table  If you have only.
CSS Border.
Today’s objectives  Assignment 1  Padding, Margins, Borders  Fluid Layout page  Building accessible Table  Element size with padding and border 
Css ( CASCADING STYLE SHEETs ) CSS Box Model. All HTML elements can be considered as boxes. In CSS, the term "box model" is used when talking about design.
CSS Table Properties.
Tutorial 5: Tables Session OBJECTIVES Marking row groups Marking column groups Setting the table frame Specifying the table’s internal gridlines.
Chcslonline.org Text –wrapping around Images. chcslonline.org To wrap text around an image, lets set up a style in our style sheet. open a new notepad.
INTRODUCTORY Tutorial 4 Exploring Graphic Elements and Images.
CIS234A- Lecture 7 Instructor Greg D’Andrea. Tables A table can be displayed on a Web page either in a text or graphical format. A text table: – contains.
Part 4 Introduction to CSS. CSS Table Table Borders table, td, th { border:1px solid black; } Firstname Lastname Bader Ali Paul Manuel The example below.
Table (TABLE) Contains TABLE ROWS (TR) Contains TABLE DATA (TD) Data can contain anything › Text › Lists › Other tables › Pictures › …
Creating Your Own Webpage COSC Cascading Stylesheets Think of: HTML: content of your webpage HTML has tags CSS: presentation and appearance of your.
Cascading Style Sheets Chapters 5-6 Color and Background Controls Border and Margin Controls.
Web Foundations THURSDAY, OCTOBER 3, 2013 LECTURE 6: CSS CONTINUED.
Advanced Web Development Instructor: Thomas Bombach.
1 CS428 Web Engineering Lecture 08 Border, Margin, Padding … (CSS - III)
CSS Layout Cascading Style Sheets. Lesson Overview  In this lesson, you will learn:  CSS Box Model  CSS properties for border  CSS properties for.
How To Create HTML Tables. Table Structure General HTML code for a Web Table: table cells table cells.
Table Styling. Using CSS to Style Tables: So far, our table styling - such has "width" and "border" - has not used CSS. CSS provides us with many tools.
CIS234A Lecture 6 Instructor Greg D’Andrea. Span and Div The span and div elements are a generic means by which we can add structure to documents. The.
CSS Box Model. What is the Box Model? Each XHTML element appearing on our page takes up a "box" or "container" of space. Each box size is affected not.
Tutorial #5 Working with the Box Model. Tutorial #4 Review - CSS Create a homework page Final Project Discussion Exam on Blackboard Styling Lists (List-style-type,
CS 120: Introduction to Web Programming Lecture 10: Extra Features and Website Design Part 1 Tarik Booker CS 120 California State University, Los Angeles.
CSS. What does it stand for? ___________________.
CSS. What does it stand for? Cascading Style Sheet.
CSS Box Model.
CSS Box Model.
Cascading Style Sheets Boxes
( Cascading style sheet )
Table Styling.
CSS Table Styling.
Table Styling.
Applying CSS to Tables Stylish Tables.
Table Styling.
Creating Your Own Webpage
CSS Table Styling.
CSS Table Styling.
Cascading Style Sheets
CSS Borders and Margins.
Second CSS Lecture Applications to XML
CSS Box Model.
Basic Tables.
Basic Tables.
More CSS 22-Feb-19.
Basic Tables.
CSS Box Model.
Principles of Web Design 5th Edition
CSS Boxes CS 1150 Fall 2016.
Presentation transcript:

CSS Table Styling

Up to this point, as we haven't applied any CSS styling to our tables, our example tables have not been too pleasing to the eye. CSS offers us several properties to customize how our tables appear on the page: StyleDescription widthWidth of element. background-colorBackground color of element. colorColor of text in element. text-alignHorizontal text alignment of element. borderBorder thickness and style of element. paddingPadding (white space around content) of element. Using CSS to Style Tables We're already familiar with the color and text-align properties, but let's see examples of the other styles in action. Though we're using these properties to style table elements, all of these properties may be used with many other XHTML elements, as we'll see in future lessons.

We can set the overall width of a table by applying a class to the element: Setting Table Width.glossary { width: 350px; }... Acronym Definition CSS Cascading Style Sheets... The table is now 350 pixels wide, creating some extra space in the data cells. The width of the columns is automatically established by the browser to accommodate the cell contents, but we don't have to accept this format.

We can set the width of columns by setting the widths of the first row of data cells: Setting Column Width in Pixels.glossary { width: 350px; }.col { width: 175px; }... Acronym Definition CSS Cascading Style Sheets... We've now set each of the columns to be 175 pixels in width, or half of the total available table width. Notice that due to the enforced width, some cell contents had to wrap to an additional line.

Rather than pixels, we can also set column widths to be a percent of the total available width: Setting Column Width in Percent.glossary { width: 350px; }.col1 { width: 30%; }.col2 { width: 70%; }... Acronym Definition... Setting column widths by percent instead of pixels has the advantage of flexibility. Should we ever alter the width of the table itself, the columns will automatically adjust.

CSS provides us plenty of flexibility when generating borders around elements. There are multiple properties that affect the border that displays on the page: Borders StyleDescription border-styleType of border: none, solid, dashed, dotted, double, groove, ridge, inset, outset. border-colorColor of border. border-widthWidth of border, measured in pixels. Also available: thin, medium, and thick. border-collapsecollapse: borders display as single border. separate: borders are detached (default). We'll examine each of the first three, but first let's take a look at the border- collapse property.

By invoking the border-collapse property, we can force a table to collapse its borders into a single line between cells: The border-collapse Property.glossary { width: 350px; }.collapse { border-collapse: collapse; } Acronym Definition... Here we created an identical table but added a class that included the border-collapse property.

By using the other three properties, we can create custom borders for our table: Customizing Borders.glossary { width: 350px; border-width: 4px; border-style: solid; border-color: red; } th { border-width: 2px; border-style: solid; } td { border-width: 2px; border-style: dashed; }... Notice that we can apply different styles to the table, table headers, and table cell elements. For demonstrative purposes, we applied CSS styles directly to the and elements, instead of using separate classes. In the real world, this would likely be a bad idea, as any other tables on our page would be affected too.

When specifying multiple border properties, we can use the CSS border shorthand to reduce the statement to a single line: Using CSS Border Shorthand.glossary { width: 350px; border: 4px solid red; } th { border: 2px solid; } td { border: 2px dashed; }....glossary { width: 350px; border-width: 4px; border-style: solid; border-color: red; } th { border-width: 2px; border-style: solid; } td { border-width: 2px; border-style: dashed; }... By convention, the properties are ordered as border: border-width border- style border-color; (The color portion may be omitted.)

By setting the padding property, we can make sure there is at least that much white space around our cell contents. This keeps the actual cell contents from displaying too closely to the borders: Adding Cell Padding.glossary { width: 350px; border: 4px solid red; } th { border: 2px solid; } td { border: 2px dashed; padding: 5px; }... Different border and padding settings can be set for the top, bottom, left, and right sides of elements. We will learn how to do this in an upcoming lesson.

By setting the background-color property, we can change our table's background away from the default: Setting a Background Color.glossary { width: 350px; border: 4px solid red; background-color: gray; } th { border: 2px solid; } td { border: 2px dashed; padding: 5px; }... Let's use this property now on the data cells to make our table a bit more readable.

Using Background Color on Rows....odd { background-color: lime; }.even { background-color: aqua; } CSS Cascading Style Sheets FAQ Frequently Asked Questions... This is a handy way to make our table rows show in alternating background colors. This technique makes reading wide tables far easier for viewers.