10. Web sites with xhtml and css - Web Front-End
-
Upload
telerik-software-academy -
Category
Technology
-
view
886 -
download
1
description
Transcript of 10. Web sites with xhtml and css - Web Front-End
![Page 1: 10. Web sites with xhtml and css - Web Front-End](https://reader038.fdocuments.us/reader038/viewer/2022103017/556350afd8b42a6f7b8b52df/html5/thumbnails/1.jpg)
Web Sites with XHTML and CSS
Slice and Dice: From PSD Image to XHTML+CSS
Svetlin Nakov
Telerik Software Academyacademy.telerik.com
Manager Technical Traininghttp://nakov.com
http://html5course.telerik.com
![Page 2: 10. Web sites with xhtml and css - Web Front-End](https://reader038.fdocuments.us/reader038/viewer/2022103017/556350afd8b42a6f7b8b52df/html5/thumbnails/2.jpg)
Table of Contents
1. From Image to XHTML+CSS: Step by Step
2. Floating DIVs and DIVs Behaving Like Tables
3. Vertical Alignment of DIVs
4. Centering Site Contents
5. Web Site with Frames
6. Web Site with Tables
7. Web Site with DIVs
8. Slice and Dice: Showcases2
![Page 3: 10. Web sites with xhtml and css - Web Front-End](https://reader038.fdocuments.us/reader038/viewer/2022103017/556350afd8b42a6f7b8b52df/html5/thumbnails/3.jpg)
From Image to XHTML+CSS
Creating Web Sites Step by Step
![Page 4: 10. Web sites with xhtml and css - Web Front-End](https://reader038.fdocuments.us/reader038/viewer/2022103017/556350afd8b42a6f7b8b52df/html5/thumbnails/4.jpg)
From Image to XHTML+CSS
Steps for converting a Web site image to XHTML + CSS ( + JavaScript )
1. Decide on the layout type Fixed width – what resolution (800, 1024, …)?
Fluid width – which parts will resize?
2. Identify site sections Header, main, footer, columns,
navigation, etc.
3. Decide on the layout model DIVs vs. tables (any good reason to
use tables?)
4
![Page 5: 10. Web sites with xhtml and css - Web Front-End](https://reader038.fdocuments.us/reader038/viewer/2022103017/556350afd8b42a6f7b8b52df/html5/thumbnails/5.jpg)
From Image to XHTML+CSS (2)
Steps for converting a Web site image to XHTML + CSS ( + JavaScript )
4. Distinguish between content and style
Text vs. images – which belongs to the content and which is part of the styling?
5. Create the page layout Create the layout DIVs and define
their CSS
6. Create the contents of each section
7. Test the site in different Web browsers
5
![Page 6: 10. Web sites with xhtml and css - Web Front-End](https://reader038.fdocuments.us/reader038/viewer/2022103017/556350afd8b42a6f7b8b52df/html5/thumbnails/6.jpg)
Fixed vs. Fluid Layout Page layout can be fixed or fluid Fixed width
Typical Web users use at least 1024 x 768 resolution 900px-1000px page width is OK
Mobile devices have smaller screen
Fluid width Ensure the main page content
resizes correctly
Beware of very large screens (e.g. 1920 x 1200)
Fix the min-width for the main <div>
6
![Page 7: 10. Web sites with xhtml and css - Web Front-End](https://reader038.fdocuments.us/reader038/viewer/2022103017/556350afd8b42a6f7b8b52df/html5/thumbnails/7.jpg)
Identifying Site Sections
Typical Web sites consist of header, main section and footer The main content usually has some
main section, sidebars or navigation controls
The main section could be split in columns
7
Header
Main Section
Footer
Left Side Bar
Right Side Bar
Columns
Columns
Columns
![Page 8: 10. Web sites with xhtml and css - Web Front-End](https://reader038.fdocuments.us/reader038/viewer/2022103017/556350afd8b42a6f7b8b52df/html5/thumbnails/8.jpg)
Frames vs. Table vs. DIVs?
Site layout with frames is old-fashioned
Using tables for columned design is incorrect! Tables are considered SEO unfriendly
The other option is to use <div> tags To place them in columns they must be
floating When they are floating, you can fix
their width, but height is determined by their content (or is fixed)
When height is determined by content, background may not be applied properly
Footer must also be floating with clear:left
8
![Page 9: 10. Web sites with xhtml and css - Web Front-End](https://reader038.fdocuments.us/reader038/viewer/2022103017/556350afd8b42a6f7b8b52df/html5/thumbnails/9.jpg)
Floating DIVs Floating DIVs are not part of their parent DIV Their height is the height of their
content The parent container's height can
be less
9
Floating-left <div>
Floating-right <div>
Non-floating <div>
The container <div> has height based on its non-
floating content
![Page 10: 10. Web sites with xhtml and css - Web Front-End](https://reader038.fdocuments.us/reader038/viewer/2022103017/556350afd8b42a6f7b8b52df/html5/thumbnails/10.jpg)
Floating DIVs
Live Demo
floating-divs.html
![Page 11: 10. Web sites with xhtml and css - Web Front-End](https://reader038.fdocuments.us/reader038/viewer/2022103017/556350afd8b42a6f7b8b52df/html5/thumbnails/11.jpg)
DIVs Behaving Like Tables
display:table makes DIVs behave like table:
Supported in all W3C-compliant browsers Internet Explorer supports this
since IE8
11
#container { display: table; }#row { display: table-row; }#left, #right, #middle { display: table-cell; }<div id="container"> <div id="row"> <div id="left">Left Column</div> <div id="middle">Middle Column</div> <div id="right">Right Column</div> </div></div>
![Page 12: 10. Web sites with xhtml and css - Web Front-End](https://reader038.fdocuments.us/reader038/viewer/2022103017/556350afd8b42a6f7b8b52df/html5/thumbnails/12.jpg)
DIVs Behaving Like TablesLive Demo
table-with-divs.html
![Page 13: 10. Web sites with xhtml and css - Web Front-End](https://reader038.fdocuments.us/reader038/viewer/2022103017/556350afd8b42a6f7b8b52df/html5/thumbnails/13.jpg)
Vertical Alignment of DIV
Aligning a DIV vertically is a complex task You need three nested <div>
elements:
13
#container { display: table; height: 400px; }#row { display: table-row; }#cell { display: table-cell; vertical-align: middle; }
<div id="container"> <div id="row"> <div id="cell">Vertically Centered</div> </div></div>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/ xhtml1-transitional.dtd">
XHTML DOCTYPE is requred, especially for IE!
![Page 14: 10. Web sites with xhtml and css - Web Front-End](https://reader038.fdocuments.us/reader038/viewer/2022103017/556350afd8b42a6f7b8b52df/html5/thumbnails/14.jpg)
Vertical Alignment of DIVs
Live Demo
div-vertical-alignment.html
![Page 15: 10. Web sites with xhtml and css - Web Front-End](https://reader038.fdocuments.us/reader038/viewer/2022103017/556350afd8b42a6f7b8b52df/html5/thumbnails/15.jpg)
Distinguish between Content and Style
Separating content from presentation The HTML content is the essential
information published in the Web page, e.g. text + images
The presentation is the layout and styles used to format the content or decorate it
The content should live in the HTML
The presentation should live in the CSS
When the CSS is disabled, the site should look like an article with titles, lists and paragraphs
15
![Page 16: 10. Web sites with xhtml and css - Web Front-End](https://reader038.fdocuments.us/reader038/viewer/2022103017/556350afd8b42a6f7b8b52df/html5/thumbnails/16.jpg)
GIF, JPEG or PNG? GIF, JPEG and PNG are the three most common image formats in the Web JPEG is used for large images, e.g.
photos
GIF and PNG support transparency
Used for bullets, icons and small images
Transparent PNG not supported by old browsers
PNG files are larger than GIF
GIF supports less colors than PNG
GIF supports animation
16
![Page 17: 10. Web sites with xhtml and css - Web Front-End](https://reader038.fdocuments.us/reader038/viewer/2022103017/556350afd8b42a6f7b8b52df/html5/thumbnails/17.jpg)
Centering a Fixed-Width Site
Several ways to center the content of the site: Placing it in <center> tag –
deprecated Using CSS text-align:center
Will affect all child nodes too
Using CSS margin:0 auto The width of the content is fixed
The left and right margins are set to automatic
17
width: 900px;margin: 20px auto;
![Page 18: 10. Web sites with xhtml and css - Web Front-End](https://reader038.fdocuments.us/reader038/viewer/2022103017/556350afd8b42a6f7b8b52df/html5/thumbnails/18.jpg)
Centering Site Contents – Example
18
<html xmlns="http://www.w3.org/1999/xhtml"><head> <style type="text/css"> body { background-color: #CCCCCC; } #site-contents { width: 940px; margin: 20px auto; } </style></head><body> <div id="site-contents"> <h1>Welcome to our Web site!</h1> ... </div></body></html>
![Page 19: 10. Web sites with xhtml and css - Web Front-End](https://reader038.fdocuments.us/reader038/viewer/2022103017/556350afd8b42a6f7b8b52df/html5/thumbnails/19.jpg)
Centered Site Contents
Live Demo
![Page 20: 10. Web sites with xhtml and css - Web Front-End](https://reader038.fdocuments.us/reader038/viewer/2022103017/556350afd8b42a6f7b8b52df/html5/thumbnails/20.jpg)
Web Site Based on Frames
Web sites based on frames Easy-to-develop Works for small and simple Web
sites Considered old-fashioned, not
recommended!
20
<frameset rows="85,*" cols="*" frameborder="no" border="0" framespacing="0"> <frame src="header.html" scrolling="no" noresize="yes" /> <frameset cols="126,*" frameborder="no" border="0" framespacing="0"> <frame src="left.html" name="leftFrame" scrolling="no" noresize="yes" /> <frame src="welcome.html" name="mainFrame" /> </frameset></frameset>
![Page 21: 10. Web sites with xhtml and css - Web Front-End](https://reader038.fdocuments.us/reader038/viewer/2022103017/556350afd8b42a6f7b8b52df/html5/thumbnails/21.jpg)
Web Site with Frames
Live Demo
![Page 22: 10. Web sites with xhtml and css - Web Front-End](https://reader038.fdocuments.us/reader038/viewer/2022103017/556350afd8b42a6f7b8b52df/html5/thumbnails/22.jpg)
Web Site Based on Tables
Web sites based on tables Easy to layout the page elements Semantically incorrect, not
recommended!
22
<table class="siteTable"> <tr class="headerRow"> <td class="logoCell">Logo</td> <td class="headerCell">Header Text</td> </tr> <tr valign="top"> <td class="menuCell">Menu</td> <td class="mainContentCell">Main Content</td> </tr> <tr class="footerRow"><td colspan="2">Footer</td></tr></table>
![Page 23: 10. Web sites with xhtml and css - Web Front-End](https://reader038.fdocuments.us/reader038/viewer/2022103017/556350afd8b42a6f7b8b52df/html5/thumbnails/23.jpg)
Web Site with TablesLive Demo
![Page 24: 10. Web sites with xhtml and css - Web Front-End](https://reader038.fdocuments.us/reader038/viewer/2022103017/556350afd8b42a6f7b8b52df/html5/thumbnails/24.jpg)
Web Site Based on DIVs Web sites based on DIVs
The best, semantically correct approach
Sometimes is hard to implement
24
<div id="header"> <div id="headerLogo">Logo</div> <div id="headerText">Header</div></div>
<div id="container"> <div id="leftSidebar">Menu</div> <div id="mainContent">Main Content</div></div>
<div id="footer">Footer</div>
![Page 25: 10. Web sites with xhtml and css - Web Front-End](https://reader038.fdocuments.us/reader038/viewer/2022103017/556350afd8b42a6f7b8b52df/html5/thumbnails/25.jpg)
Web Site with DIVsLive Demo
![Page 26: 10. Web sites with xhtml and css - Web Front-End](https://reader038.fdocuments.us/reader038/viewer/2022103017/556350afd8b42a6f7b8b52df/html5/thumbnails/26.jpg)
Creating a Web SiteSlice and Dice: Showcases
![Page 27: 10. Web sites with xhtml and css - Web Front-End](https://reader038.fdocuments.us/reader038/viewer/2022103017/556350afd8b42a6f7b8b52df/html5/thumbnails/27.jpg)
Slice and Dice Showcase
We should convert the following image to XHTML+CSS:
27
![Page 28: 10. Web sites with xhtml and css - Web Front-End](https://reader038.fdocuments.us/reader038/viewer/2022103017/556350afd8b42a6f7b8b52df/html5/thumbnails/28.jpg)
Layout and Style Fixed width or fluid width?
Fixed width will work well
Need to center the content and use some background to fill the rest of the page
Frames, tables or DIVs? DIVs with table layout will work
best
28
![Page 29: 10. Web sites with xhtml and css - Web Front-End](https://reader038.fdocuments.us/reader038/viewer/2022103017/556350afd8b42a6f7b8b52df/html5/thumbnails/29.jpg)
Step 1 – Determine the Pieces
First step is to determine the parts of the design
29
![Page 30: 10. Web sites with xhtml and css - Web Front-End](https://reader038.fdocuments.us/reader038/viewer/2022103017/556350afd8b42a6f7b8b52df/html5/thumbnails/30.jpg)
Step 1 – Determine the Pieces (2)
30
the site header - divthe site header - divThis is the logo –should be image
tag
This is the logo –should be image
tagThis can be background
image
This can be background
image
![Page 31: 10. Web sites with xhtml and css - Web Front-End](https://reader038.fdocuments.us/reader038/viewer/2022103017/556350afd8b42a6f7b8b52df/html5/thumbnails/31.jpg)
Step 1 – Determine the Pieces (3)
31
3 columns designBest way is – table, one row, three
cells
3 columns designBest way is – table, one row, three
cells
Menu cellMenu cell Body cellBody cell Right cellRight cell
![Page 32: 10. Web sites with xhtml and css - Web Front-End](https://reader038.fdocuments.us/reader038/viewer/2022103017/556350afd8b42a6f7b8b52df/html5/thumbnails/32.jpg)
Step 1 – Determine the Pieces (4)
32
Footer – div, center the text with CSS
Footer – div, center the text with CSS
![Page 33: 10. Web sites with xhtml and css - Web Front-End](https://reader038.fdocuments.us/reader038/viewer/2022103017/556350afd8b42a6f7b8b52df/html5/thumbnails/33.jpg)
Step 1 – Determine the Pieces (5)
33
Unordered lists, strong tags, linksUnordered lists,
strong tags, links
DIV with links (A tags)
DIV with links (A tags)
Article headings
(H1 and H2 tags)
Article headings
(H1 and H2 tags)
two separate lists in table or two floating divs
two separate lists in table or two floating divs
![Page 34: 10. Web sites with xhtml and css - Web Front-End](https://reader038.fdocuments.us/reader038/viewer/2022103017/556350afd8b42a6f7b8b52df/html5/thumbnails/34.jpg)
Step 2 – Which Parts are Image and Which
HTML? Use HTML when possible to avoid images
Images are slower to download and render
34
This bullets can be either CSS background image or default list
bullet
This bullets can be either CSS background image or default list
bullet
Browsers do not support such font and effects so we have to place this text using
image
Browsers do not support such font and effects so we have to place this text using
image
All elements backgrounds and
borders are solid so we can use css colors
instead of images
All elements backgrounds and
borders are solid so we can use css colors
instead of images
![Page 35: 10. Web sites with xhtml and css - Web Front-End](https://reader038.fdocuments.us/reader038/viewer/2022103017/556350afd8b42a6f7b8b52df/html5/thumbnails/35.jpg)
Step 3 – The Small Details
Look for the small details and decide if they should be in CSS, HTML or image
35
Example: this images have border that
should be defined in the CSS, not part of
the image
Example: this images have border that
should be defined in the CSS, not part of
the image
![Page 37: 10. Web sites with xhtml and css - Web Front-End](https://reader038.fdocuments.us/reader038/viewer/2022103017/556350afd8b42a6f7b8b52df/html5/thumbnails/37.jpg)
Case Study: Text or Image
Three ways to create the top part: Use text over background image,
absolute positioned DIVs Use table, slice the image to fit the
needed rows and columns Leave the text in the image
37
![Page 38: 10. Web sites with xhtml and css - Web Front-End](https://reader038.fdocuments.us/reader038/viewer/2022103017/556350afd8b42a6f7b8b52df/html5/thumbnails/38.jpg)
Case Study:Two Backgrounds
To achieve the underline and the leaf image we can use only CSS. We need two tags: Outer tag has the leaf as background
image, padding-left so the inner doesn’t cover it
Inner tag has the underline as background image, repeat-x, positioned in the bottom
Note: the underline background image is 1px wide to save bandwidth!
38
![Page 39: 10. Web sites with xhtml and css - Web Front-End](https://reader038.fdocuments.us/reader038/viewer/2022103017/556350afd8b42a6f7b8b52df/html5/thumbnails/39.jpg)
Case Study:Rounded Corners
Rounded border corners are supported by CSS3 Not yet supported by most browsers
But soon will be
We can create them with multiple images in table
Too much code
39
![Page 40: 10. Web sites with xhtml and css - Web Front-End](https://reader038.fdocuments.us/reader038/viewer/2022103017/556350afd8b42a6f7b8b52df/html5/thumbnails/40.jpg)
форум програмиране, форум уеб дизайнкурсове и уроци по програмиране, уеб дизайн – безплатно
програмиране за деца – безплатни курсове и уроцибезплатен SEO курс - оптимизация за търсачки
уроци по уеб дизайн, HTML, CSS, JavaScript, Photoshop
уроци по програмиране и уеб дизайн за ученициASP.NET MVC курс – HTML, SQL, C#, .NET, ASP.NET MVC
безплатен курс "Разработка на софтуер в cloud среда"
BG Coder - онлайн състезателна система - online judge
курсове и уроци по програмиране, книги – безплатно от Наков
безплатен курс "Качествен програмен код"
алго академия – състезателно програмиране, състезания
ASP.NET курс - уеб програмиране, бази данни, C#, .NET, ASP.NETкурсове и уроци по програмиране – Телерик академия
курс мобилни приложения с iPhone, Android, WP7, PhoneGap
free C# book, безплатна книга C#, книга Java, книга C#Дончо Минков - сайт за програмиранеНиколай Костов - блог за програмиранеC# курс, програмиране, безплатно
?
? ? ??
?? ?
?
?
?
??
?
?
? ?
Questions?
?
Web Sites with XHTML and CSS
http://academy.telerik.com
![Page 41: 10. Web sites with xhtml and css - Web Front-End](https://reader038.fdocuments.us/reader038/viewer/2022103017/556350afd8b42a6f7b8b52df/html5/thumbnails/41.jpg)
Exercises1. Create this with XHTML and CSS. Using
tables and frames are not allowed!
41
See the file: site-sample.png
![Page 42: 10. Web sites with xhtml and css - Web Front-End](https://reader038.fdocuments.us/reader038/viewer/2022103017/556350afd8b42a6f7b8b52df/html5/thumbnails/42.jpg)
Exercises (2)
2. Create this with XHTML and CSS. Using tables and frames is not allowed!
42
See the file: architecture.psd
![Page 43: 10. Web sites with xhtml and css - Web Front-End](https://reader038.fdocuments.us/reader038/viewer/2022103017/556350afd8b42a6f7b8b52df/html5/thumbnails/43.jpg)
Free Trainings @ Telerik Academy
"Web Design with HTML 5, CSS 3 and JavaScript" course @ Telerik Academy html5course.telerik.com
Telerik Software Academy academy.telerik.com
Telerik Academy @ Facebook facebook.com/TelerikAcademy
Telerik Software Academy Forums forums.academy.telerik.com