Download presentation
Presentation is loading. Please wait.
Published byElijah Maximillian Simmons Modified over 8 years ago
1
Tables HTML and CSS with Tables CSCI 1710 Web Design and Development
2
What we now know about CSS
3
Ways to Define Styles Style sheet rule syntax Property/value pairs separated by semicolon selector {property: value; } Simple: h1 { color: red; } h2, h3 { color: rgb(0,0,200); } blockquote { font-style: italic; } More Complex: p {p { width: 500px; background-color: #FFFCD5; color: #241DFF; border: 1px solid black; margin: 0 auto; font-style: italic; font-family: Arial; }
4
Ways to Define Styles One or more rules contained in an external style sheet (linked) contained in an internal style sheet (embedded) applied directly to a tag (inline)
5
External Style Sheets One way we can implement CSS is through external (linked) style sheets With external style sheets we create a second document and name it with a.css extension This second file contains only the CSS expressions Preferred method for employing CSS External stylesheets allow for modifying style across multiple HTML documents from a single location
6
External Style Sheets Within every page that needs to use the external style sheet, we add the following tag to the head section of the document: The advantage to external style sheets is that we can create one css file and our entire website use the one file
7
External Style Sheet (index.html) Basic web page rel = relationship href = hypertext reference – the path to the external sheet
8
Embedded Style Sheets Embedded style sheets are defined in the head section of the document selector { property:value; } selector { property:value; } Embedded style sheets are used to apply style to one individual web page
9
Embedded Style Sheets … h1{ color: red; font-size: 36px; } p{ color: green; font-family:arial; } Basic web page …
10
Inline Style Option three is declaring CSS inline. Inline allows us to add CSS to one specific tag within a document … Hello
11
Order of Operation Inline style=> ‘Winner takes all’ Embedded style External (Linked) Style Browser default
12
Commenting In CSS, we can apply comments to embedded and linked CSS. To place a comment we use the /* COMMENT */ format /* this is style.css */ h1 { color: red; font-size: 36px; }
13
Commenting For all.css files created, you must have the following comment block: /* Name:Your Name Course:CSCI 1710 Assignment:Lab x Due Date:xx.xx.2016 Purpose:The purpose of this.css is to style my index.html page */
14
Colors When working with colors, we have a few different options to express the value of the color One option is to use the named colors There are 17 standard colors aqua, black, blue, fuchsia, gray, green, lime, maroon, navy, olive, orange, purple, red, silver, teal, white, and yellow There are 123 additional colors i.e. BlanchedAlmond, ForestGreen, HoneyDew, LightGoldenRodYellow, WhiteSmoke
15
Colors R G B Red255, #FF 0 0 Green 0255, #FF 0 Blue 0 0255, #FF White255, #FF 255, #FF 255, #FF Black 0 0 0
16
Colors Another option would be to express the RGB values using hexadecimal values R G B color: #FF FF FF; color: #FF0000; /* This would be red */ color: #C9C9C9; /* This would be medium gray */
17
Colors RGB values Another option is expressing the red, green, and blue values in decimal format. rgb(RED, GREEN, BLUE); color: rgb(255, 0, 0); /* red */ color: rgb(125, 125, 125); /* gray */
18
Colors RGBA Very similar to option three, however this allows us to identify the opacity of the object by setting the Alpha parameter. This ranges from 0.0 (fully transparent) to 1.0 (fully opaque) color: rgba(RED, GREEN, BLUE, ALPHA); color: rgba(255, 0, 0, 0.3); /* red with transparency */
19
Colors So to change the font color of a paragraph to white we could do any one of the following: p { color: white; } p { color: #FFFFFF; } p { color: rgb(255,255,255); } p { color: rgba(255,255,255,1.0); }
20
Choosing Colors As we learned from our first homework assignment, poor choice of display colors can ruin an otherwise good web site, and potentially a visitor’s eyesight All joking aside, a badly executed color scheme will encourage users to find other sites Several online tools are available that can help a developer select an effective set of colors for a web site
21
Choosing Colors Adobe Kuler or Color Wheel CC https://color.adobe.com/create/color-wheel/
22
Choosing Colors Paletton http://www.paletton.com
23
Choosing Colors One of the tasks in Phase 3 of the semester project is submitting the color palette you intend to use for your web site PalettonAdobe
24
Choosing Colors For this phase, DO NOT say, ‘I intend to use shades of blue and gray,’ or something like that. Pick a color palette, take a screen shot, and include it in your submission PalettonAdobe
25
IDs, Classes, and Divs
26
ID Attribute ids and classes can be written to apply a group of rules selectively to elements on a web page An id can only be used once on a given web page A class can be used multiple times on a web page id and class names should start with a letter or an underscore (_), not a number or any other character
27
Syntax and Usage id=“_dynamicText”<- Syntax … <- Usage class=“content” <- Syntax … <- Usage * ids used more with Javascript, now, but still work in CSS
28
The div Element Allows you to group a set of elements together in one block level box (container) Typically used to define a web page’s structure, or layout Page layout is the part of graphic design that deals in the arrangement of visual elements on a page It generally involves organizational principles of composition to achieve specific communication objectives (More on that later)
29
Body Header Nav … Content Footer Heading Paragraph E XAMPLE L AYOUT
30
…more CSS: The Box Model It’s kind of a big thing…
31
The Box Model A very important concept in CSS Applies to block level elements Each is regarded as a nested box with four parts: Content Padding Border Margin
32
The Box Model Content: The space where the page’s content is displayed Padding: Space between a box’s border and content. Adding padding can improve readability of the content. Default = 0 Border: Wraps around the padding and content. Doesn’t include the margin. Default = 0 Margin: Area outside of the border. Can create a gap between adjacent boxes. Default = 0
33
The Box Model By default, the content box is rendered just big enough to hold what it contains By default, padding, border, and margin are 0 We can modify any or all of the three to modify the presentation of our content using CSS
34
Box Dimensions width, height By default, a box is sized by a browser to be just big enough to hold its content You can explicitly set the width and height in CSS Height doesn’t always work very well
35
MARGIN PADDING CONTENT BORDER The Box Model
36
MARGIN PADDING CONTENT BORDER The Box Model MARGIN PADDING CONTENT BORDER
37
CSS Box Model Examples
38
The Box Model So the box can be modified to visually separate one block of content from another, improving its presentation Web design is about more than just writing code Arranging content based on established best practices to make it attractive for visitors and thus likely to engage them in the future
39
The Box Model Padding, border, and margin can be set one of four ways: Specifying top, right, bottom, and left values Specifing top/bottom and right/left values Specifying a single value that applies to top, right, bottom, and left padding-top: 5px; padding-right: 10px; padding-bottom: 15px; padding-left: 5px; margin: 10px 15px; border-size: 10px; *Note: border-style and border-color also have to be set for border to display
40
The Box Model Padding, border, and margin can be set one of four ways: Specifying all four on one line margin: 10px 15px 5px 25px;
41
Tables
42
Historically, tables often used in HTML for page layout and text alignment. CSS techniques now used for this HTML tables should only be used for rendering data that belongs naturally in a grid, in other words where the data describe a number of objects that have the same properties Tables should never be used for layout
44
Taxonomy of tables Cell Cells merged together Column Row
45
Table Tags.. beginning and end of a table.. beginning and end of a row.. beginning and end of a cell Tables are laid out row by row, top to bottom, left to right ham eggs milk juice
46
item quantity milk 2 cups Table headings.. beginning and end of a table heading. By default, all major browsers display as bold and center
47
Tables, programmatically (an algorithm) 1.Write table opening tag 2.If there is a heading row 1.Write heading row opening tag 2.Write current header cell opening tag 3.Write current header cell data 4.Write current header cell closing tag 5.Write heading row closing tag 3.While there are still rows 1.Write current row opening tag 2.While there are still cells for the current row 1.Write current cell opening tag 2.Enter table data 3.Write current cell closing tag 3.Write current row closing tag 4.Write table end tag If there’s another…
48
Spanning Cells 1 2 3 4 5 6 7 Cells can be joined using rowspan (for vertical joining) and colspan (for horizontal joining) attribute on td tag rowspan=“n” or colspan=“n” n represents number of rows or columns to span across
50
Spanning Cells When writing code for a table that includes merged cells, pencil and paper can make the job easier Remember, HTML draws tables row by row Draw out the proposed table by hand It may help to put tags around each row and tags above each column
51
Spanning Cells
52
1 2 3 4 5 6 7 8 9 10 Spanning Cells 10 9 8 7 4 5 6 1 2 3
53
Spanning Cells So, using our hand drawn diagram, the code for a complex table can easily be written Remember, the number of cells in each row must be equal Cells that span rows or columns have to be accounted for
54
Tables – Fixing Column Width We can fix the width of tables’ columns by using standalone tags inside the table element in the HTML with inline CSS
55
Table Examples HTML and CSS with Tables
56
Sources “HTML Reference”, W3Schools, Retrieved from http://www.w3schools.com/tags/default.asp “HTML Tables”, W3Schools, Retrieved from http://www.w3schools.com/html/html_tables.asp “CSS Reference”, W3Schools, Retrieved from http://www.w3schools.com/cssref/default.asphttp://www.w3schools.com/cssref/default.asp “HTML Tables – when and how to use tables in HTML”, Ben Hunt’s Web Design from Scratch, Retrieved from http://webdesignfromscratch.com/html-css/html-tables/
57
Copyrights Microsoft, Windows, Excel, Outlook, and PowerPoint are registered trademarks of Microsoft Corporation. IBM, DB2, DB2 Universal Database, System i, System i5, System p, System p5, System x, System z, System z10, System z9, z10, z9, iSeries, pSeries, xSeries, zSeries, eServer, z/VM, z/OS, i5/OS, S/390, OS/390, OS/400, AS/400, S/390 Parallel Enterprise Server, PowerVM, Power Architecture, POWER6+, POWER6, POWER5+, POWER5, POWER, OpenPower, PowerPC, BatchPipes, BladeCenter, System Storage, GPFS, HACMP, RETAIN, DB2 Connect, RACF, Redbooks, OS/2, Parallel Sysplex, MVS/ESA, AIX, Intelligent Miner, WebSphere, Netfinity, Tivoli and Informix are trademarks or registered trademarks of IBM Corporation. Linux is the registered trademark of Linus Torvalds in the U.S. and other countries. Oracle is a registered trademark of Oracle Corporation. HTML, XML, XHTML and W3C are trademarks or registered trademarks of W3C®, World Wide Web Consortium, Massachusetts Institute of Technology. Java is a registered trademark of Sun Microsystems, Inc. JavaScript is a registered trademark of Sun Microsystems, Inc., used under license for technology invented and implemented by Netscape. SAP, R/3, SAP NetWeaver, Duet, PartnerEdge, ByDesign, SAP Business ByDesign, and other SAP products and services mentioned herein as well as their respective logos are trademarks or registered trademarks of SAP AG in Germany and other countries. Business Objects and the Business Objects logo, BusinessObjects, Crystal Reports, Crystal Decisions, Web Intelligence, Xcelsius, and other Business Objects products and services mentioned herein as well as their respective logos are trademarks or registered trademarks of Business Objects S.A. in the United States and in other countries. Business Objects is an SAP company. ERPsim is a registered copyright of ERPsim Labs, HEC Montreal. Other products mentioned in this presentation are trademarks of their respective owners. Presentation prepared by and copyright of John Ramsey, East Tennessee State University, Department of Computing. (ramseyjw@etsu.edu)ramseyjw@etsu.edu
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.