This document discusses CSS (Cascading Style Sheets) and separating content from presentation using CSS. It provides definitions of CSS and explains the advantages of using CSS such as greater control over layout and appearance, easier maintenance, and improved accessibility. It demonstrates how mixing presentation and content in HTML makes pages difficult to maintain and change, while separating the two with CSS allows changing styles in one place rather than many locations in the HTML. The concept of cascading styles is introduced, where more specific styles override general styles.
Presentation for the Denver HTML5 Users Group on advanced HTML techniques.
Focuses, specifically, on semantic markup (POSH), new HTML5 structural elements, microformats, microdata and ARIA landmark roles
A presentation for Dundee University's Hack Day explaining the technologies to use and how to hack your own APIs by using Yahoo! Pipes and scraping RSS feeds.
Extreme CSS Techniques - MadWorld Europe 2018, Scott DeLoach, ClickStartScott DeLoach
In this presentation, I will demonstrate expert-level CSS techniques, including how to use future CSS features today. We will discuss what’s being developed in the latest CSS recommendations, what works now, and tricks that can be used to make next-level CSS work in MadCap Flare and in today’s browsers.
http://www.clickstart.net
An overview of web development essentials that will help you as a user experience designer to not only understand how to integrate designs with development components, but also to learn some tips on interacting effectively with developers.
Celebrating the Release of Computing Careers and DisciplinesRandy Connolly
Talk given at CANNEXUS 2020 on the release of our Computing Careers and Disciplines booklet, which has gone on to be downloaded over 200000 times since its release.
Public Computing Intellectuals in the Age of AI CrisisRandy Connolly
This talk advocates for a conceptual archetype (the Public Computer Intellectual) as a way of practically imagining the expanded possibilities of academic practice in the computing disciplines, one that provides both self-critique and an outward-facing orientation towards the public good.
Presentation for the Denver HTML5 Users Group on advanced HTML techniques.
Focuses, specifically, on semantic markup (POSH), new HTML5 structural elements, microformats, microdata and ARIA landmark roles
A presentation for Dundee University's Hack Day explaining the technologies to use and how to hack your own APIs by using Yahoo! Pipes and scraping RSS feeds.
Extreme CSS Techniques - MadWorld Europe 2018, Scott DeLoach, ClickStartScott DeLoach
In this presentation, I will demonstrate expert-level CSS techniques, including how to use future CSS features today. We will discuss what’s being developed in the latest CSS recommendations, what works now, and tricks that can be used to make next-level CSS work in MadCap Flare and in today’s browsers.
http://www.clickstart.net
An overview of web development essentials that will help you as a user experience designer to not only understand how to integrate designs with development components, but also to learn some tips on interacting effectively with developers.
Celebrating the Release of Computing Careers and DisciplinesRandy Connolly
Talk given at CANNEXUS 2020 on the release of our Computing Careers and Disciplines booklet, which has gone on to be downloaded over 200000 times since its release.
Public Computing Intellectuals in the Age of AI CrisisRandy Connolly
This talk advocates for a conceptual archetype (the Public Computer Intellectual) as a way of practically imagining the expanded possibilities of academic practice in the computing disciplines, one that provides both self-critique and an outward-facing orientation towards the public good.
Lightning Talk given at the start of the celebration evening for the ten-year anniversary of our Bachelor of Computer Information Systems at Mount Royal University.
Facing Backwards While Stumbling Forwards: The Future of Teaching Web Develop...Randy Connolly
Talk given at SIGCSE'19. Web development continues to grow as an essential skill and knowledge area for employed computer science graduates. Yet within the ACM CS2013 curriculum recommendation and within computing education research in general, web development has been shrinking or even disappearing all together. This paper uses an informal systematic literature review methodology to answer three research questions: what approaches are being advocated in existing web development education research, what are current trends in industry practice, and how should web development be taught in light of these current trends. Results showed a significant mismatch between the type of web development typically taught in higher education settings in comparison to web development in industry practice. Consequences for the pedagogy of web development courses, computer science curriculum in general, and for computing education research are also discussed.
Mid-semester presentation for my Computers & Society course at Mount Royal University. Has some technical detail about how the internet works, web protocols, data centres, and typical security threats.
Helping Prospective Students Understand the Computing DisciplinesRandy Connolly
Presentation at Cannexus 2018 in Ottawa in which we discussed the results of our three-year research project on student understandings of the computing disciplines and described the 32-page full-color booklet for advisers and prospective students.
Keynote address at barcamp: the next web conference in Salzburg on April 21, 2017. The presentation explains why textbooks in this area still make sense and describes the difficulties in writing a textbook in this area.
Talk given at University of Applied Sciences at Krems , Austria for Master Forum 2017. Provides a rich overview of contemporary web development suitable for managers and business people.
Disrupting the Discourse of the "Digital Disruption of _____"Randy Connolly
Talk given at University of Applied Sciences for Management and Communication in Vienna in January 2017. It critically interrogates the narrative of digital disruption. It will describe some of the contemporary psychological and social research about the digital lifeworld and make some broader observations about how to best think about technological change.
Every year at our new student orientation, I used to give this talk to our first year students. Instead of telling them what they should do to achieve success, we thought it would be more effective and humourous to tell them instead how best to fail your courses. This was the last version of this talk from 2017.
Red Fish Blue Fish: Reexamining Student Understanding of the Computing Discip...Randy Connolly
This 2016 presentation (for a paper) updates the findings of a multi-year study that is surveying major and non-major students’ understanding of the different computing disciplines. This study is a continuation of work first presented by Uzoka et al in 2013, which in turn was an expansion of work originally conducted by Courte and Bishop-Clark from 2009. In the current study, data was collected from 668 students from four universities from three different countries. Results show that students in general were able to correctly match computing tasks with specific disciplines, but were not as certain as the faculty about the degree of fit. Differences in accuracy between student groups were, however, discovered. Software engineering and computer science students had statistically significant lower accuracy scores than students from other computing disciplines. Consequences and recommendations for advising and career counselling are discussed.
Constructing and revising a web development textbookRandy Connolly
A Pecha Kucha for WWW2016 in Montreal. Web development is widely considered to be a difficult topic to teach successfully within post-secondary computing programs. One reason for this difficulty is the large number of shifting technologies that need to be taught along with the conceptual complexity that needs to be mastered by both student and professor. Another challenge is helping students see the scope of web development, and their role in an era where the web is a part of everyday human affairs. This presentation describes our 2014 textbook and our plans for a second edition revision (which will be published in early 2017).
Computing is Not a Rock Band: Student Understanding of the Computing DisciplinesRandy Connolly
This presentation reports the initial findings of a multi-year study that is surveying major and non-major students’ understanding of the different computing disciplines. This study is based on work originally conducted by Courte and Bishop-Clark from 2009, but which uses a broadened study instrument that provided additional forms of analysis. Data was collected from 199 students from a single institution who were computer science, information systems/information technology and non-major students taking a variety of introductory computing courses. Results show that undergraduate computing students are more likely to rate tasks as being better fits to computer disciplines than are their non-major (NM) peers. Uncertainty among respondents did play a large role in the results and is discussed alongside implications for teaching and further research.
Citizenship: How do leaders in universities think about and experience citize...Randy Connolly
This presentation explores the concept of citizenship based on the experience of student leaders from a mid-sized university in western Canada. Five student leaders participated in semi-structured individual interviews to explore their experience with, and understanding of, citizenship. Interviews concentrated on personal view points and definitions of citizenship, explored whether or not there are “good” and “great” citizens, and the role universities play in fostering strong citizenship amongst its student body. The measurement of citizenship and opportunities to foster citizenship were also explored. Qualitative content analysis revealed five themes, including political participation, social citizenship/solidarity, engagement, transformative action and autonomy. Citizenship, while highly valued by this population, also appears to be impossible to measure. If post-secondary institutions are aiming to create better citizens, more work needs to be done to create a common understanding of the intended outcome. Based on these findings, a new potential model of citizenship is proposed, in line with the work of Dalton and others who emphasize a shift towards personal involvement over traditional political engagement. Further, these results suggest that students could benefit from understanding themselves as political agents, capable of inculcating change within the university context and beyond.
Presentation for a guest lecture for a colleague's Media History and Contemporary Issues course. She wanted me to cover technological determinism and social constructivism, as well as through in some content about my research on multitasking and online reading.
A longitudinal examination of SIGITE conference submission dataRandy Connolly
Presents our examination of submission data for the SIGITE conference between the years 2007-2012. SIGITE is an ACM computing conference on IT education. The presentation describes which external factors and which internal characteristics of the submissions are related to eventual reviewer ratings. Ramifications of the findings for future authors and conference organizers are also discussed. If you want to read the full paper, visit http://dl.acm.org/citation.cfm?id=2656450.2656465
This presentation is based on the 16th chapter of our textbook Fundamentals of Web Development. The book is published by Addison-Wesley. It can be purchased via http://www.amazon.com/Fundamentals-Web-Development-Randy-Connolly/dp/0133407152.
This book is intended to be used as a textbook on web development suitable for intermediate to upper-level computing students. It may also be of interest to a non-student reader wanting a single book that encompasses the entire breadth of contemporary web development.
This book will be the first in what will hopefully be a textbook series. Each book in the series will have the same topics and coverage but each will use a different web development environment. The first book in the series will use PHP.
To learn more about the book, visit http://www.funwebdev.com.
GraphRAG is All You need? LLM & Knowledge GraphGuy Korland
Guy Korland, CEO and Co-founder of FalkorDB, will review two articles on the integration of language models with knowledge graphs.
1. Unifying Large Language Models and Knowledge Graphs: A Roadmap.
https://arxiv.org/abs/2306.08302
2. Microsoft Research's GraphRAG paper and a review paper on various uses of knowledge graphs:
https://www.microsoft.com/en-us/research/blog/graphrag-unlocking-llm-discovery-on-narrative-private-data/
Transcript: Selling digital books in 2024: Insights from industry leaders - T...BookNet Canada
The publishing industry has been selling digital audiobooks and ebooks for over a decade and has found its groove. What’s changed? What has stayed the same? Where do we go from here? Join a group of leading sales peers from across the industry for a conversation about the lessons learned since the popularization of digital books, best practices, digital book supply chain management, and more.
Link to video recording: https://bnctechforum.ca/sessions/selling-digital-books-in-2024-insights-from-industry-leaders/
Presented by BookNet Canada on May 28, 2024, with support from the Department of Canadian Heritage.
Essentials of Automations: Optimizing FME Workflows with ParametersSafe Software
Are you looking to streamline your workflows and boost your projects’ efficiency? Do you find yourself searching for ways to add flexibility and control over your FME workflows? If so, you’re in the right place.
Join us for an insightful dive into the world of FME parameters, a critical element in optimizing workflow efficiency. This webinar marks the beginning of our three-part “Essentials of Automation” series. This first webinar is designed to equip you with the knowledge and skills to utilize parameters effectively: enhancing the flexibility, maintainability, and user control of your FME projects.
Here’s what you’ll gain:
- Essentials of FME Parameters: Understand the pivotal role of parameters, including Reader/Writer, Transformer, User, and FME Flow categories. Discover how they are the key to unlocking automation and optimization within your workflows.
- Practical Applications in FME Form: Delve into key user parameter types including choice, connections, and file URLs. Allow users to control how a workflow runs, making your workflows more reusable. Learn to import values and deliver the best user experience for your workflows while enhancing accuracy.
- Optimization Strategies in FME Flow: Explore the creation and strategic deployment of parameters in FME Flow, including the use of deployment and geometry parameters, to maximize workflow efficiency.
- Pro Tips for Success: Gain insights on parameterizing connections and leveraging new features like Conditional Visibility for clarity and simplicity.
We’ll wrap up with a glimpse into future webinars, followed by a Q&A session to address your specific questions surrounding this topic.
Don’t miss this opportunity to elevate your FME expertise and drive your projects to new heights of efficiency.
UiPath Test Automation using UiPath Test Suite series, part 4DianaGray10
Welcome to UiPath Test Automation using UiPath Test Suite series part 4. In this session, we will cover Test Manager overview along with SAP heatmap.
The UiPath Test Manager overview with SAP heatmap webinar offers a concise yet comprehensive exploration of the role of a Test Manager within SAP environments, coupled with the utilization of heatmaps for effective testing strategies.
Participants will gain insights into the responsibilities, challenges, and best practices associated with test management in SAP projects. Additionally, the webinar delves into the significance of heatmaps as a visual aid for identifying testing priorities, areas of risk, and resource allocation within SAP landscapes. Through this session, attendees can expect to enhance their understanding of test management principles while learning practical approaches to optimize testing processes in SAP environments using heatmap visualization techniques
What will you get from this session?
1. Insights into SAP testing best practices
2. Heatmap utilization for testing
3. Optimization of testing processes
4. Demo
Topics covered:
Execution from the test manager
Orchestrator execution result
Defect reporting
SAP heatmap example with demo
Speaker:
Deepak Rai, Automation Practice Lead, Boundaryless Group and UiPath MVP
Securing your Kubernetes cluster_ a step-by-step guide to success !KatiaHIMEUR1
Today, after several years of existence, an extremely active community and an ultra-dynamic ecosystem, Kubernetes has established itself as the de facto standard in container orchestration. Thanks to a wide range of managed services, it has never been so easy to set up a ready-to-use Kubernetes cluster.
However, this ease of use means that the subject of security in Kubernetes is often left for later, or even neglected. This exposes companies to significant risks.
In this talk, I'll show you step-by-step how to secure your Kubernetes cluster for greater peace of mind and reliability.
JMeter webinar - integration with InfluxDB and GrafanaRTTS
Watch this recorded webinar about real-time monitoring of application performance. See how to integrate Apache JMeter, the open-source leader in performance testing, with InfluxDB, the open-source time-series database, and Grafana, the open-source analytics and visualization application.
In this webinar, we will review the benefits of leveraging InfluxDB and Grafana when executing load tests and demonstrate how these tools are used to visualize performance metrics.
Length: 30 minutes
Session Overview
-------------------------------------------
During this webinar, we will cover the following topics while demonstrating the integrations of JMeter, InfluxDB and Grafana:
- What out-of-the-box solutions are available for real-time monitoring JMeter tests?
- What are the benefits of integrating InfluxDB and Grafana into the load testing stack?
- Which features are provided by Grafana?
- Demonstration of InfluxDB and Grafana using a practice web application
To view the webinar recording, go to:
https://www.rttsweb.com/jmeter-integration-webinar
State of ICS and IoT Cyber Threat Landscape Report 2024 previewPrayukth K V
The IoT and OT threat landscape report has been prepared by the Threat Research Team at Sectrio using data from Sectrio, cyber threat intelligence farming facilities spread across over 85 cities around the world. In addition, Sectrio also runs AI-based advanced threat and payload engagement facilities that serve as sinks to attract and engage sophisticated threat actors, and newer malware including new variants and latent threats that are at an earlier stage of development.
The latest edition of the OT/ICS and IoT security Threat Landscape Report 2024 also covers:
State of global ICS asset and network exposure
Sectoral targets and attacks as well as the cost of ransom
Global APT activity, AI usage, actor and tactic profiles, and implications
Rise in volumes of AI-powered cyberattacks
Major cyber events in 2024
Malware and malicious payload trends
Cyberattack types and targets
Vulnerability exploit attempts on CVEs
Attacks on counties – USA
Expansion of bot farms – how, where, and why
In-depth analysis of the cyber threat landscape across North America, South America, Europe, APAC, and the Middle East
Why are attacks on smart factories rising?
Cyber risk predictions
Axis of attacks – Europe
Systemic attacks in the Middle East
Download the full report from here:
https://sectrio.com/resources/ot-threat-landscape-reports/sectrio-releases-ot-ics-and-iot-security-threat-landscape-report-2024/
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Tobias Schneck
As AI technology is pushing into IT I was wondering myself, as an “infrastructure container kubernetes guy”, how get this fancy AI technology get managed from an infrastructure operational view? Is it possible to apply our lovely cloud native principals as well? What benefit’s both technologies could bring to each other?
Let me take this questions and provide you a short journey through existing deployment models and use cases for AI software. On practical examples, we discuss what cloud/on-premise strategy we may need for applying it to our own infrastructure to get it to work from an enterprise perspective. I want to give an overview about infrastructure requirements and technologies, what could be beneficial or limiting your AI use cases in an enterprise environment. An interactive Demo will give you some insides, what approaches I got already working for real.
Key Trends Shaping the Future of Infrastructure.pdfCheryl Hung
Keynote at DIGIT West Expo, Glasgow on 29 May 2024.
Cheryl Hung, ochery.com
Sr Director, Infrastructure Ecosystem, Arm.
The key trends across hardware, cloud and open-source; exploring how these areas are likely to mature and develop over the short and long-term, and then considering how organisations can position themselves to adapt and thrive.
Neuro-symbolic is not enough, we need neuro-*semantic*Frank van Harmelen
Neuro-symbolic (NeSy) AI is on the rise. However, simply machine learning on just any symbolic structure is not sufficient to really harvest the gains of NeSy. These will only be gained when the symbolic structures have an actual semantics. I give an operational definition of semantics as “predictable inference”.
All of this illustrated with link prediction over knowledge graphs, but the argument is general.
UiPath Test Automation using UiPath Test Suite series, part 3DianaGray10
Welcome to UiPath Test Automation using UiPath Test Suite series part 3. In this session, we will cover desktop automation along with UI automation.
Topics covered:
UI automation Introduction,
UI automation Sample
Desktop automation flow
Pradeep Chinnala, Senior Consultant Automation Developer @WonderBotz and UiPath MVP
Deepak Rai, Automation Practice Lead, Boundaryless Group and UiPath MVP
2. 1 INTRODUCTION
2 HTML
3 TABLES
4 FORMS
5 HTTP
6 CSS
7 CSS FRAMEWORKS
8 DIGITAL MEDIA
2 9 USABILITY
3. What is CSS?
3
Cascading St l Sh t (CSS) i the W3C
C di Style Sheets is h W3C-approved d
method for specifying and enriching the visual
p
presentation of web pages.
p g
CSS is not HTML but does enhance HTML by allowing
you to redefine how pre-existing tags work.
A style sheet is written according to the grammar
defined in the W3C CSS 1 or CSS 2 recommendations.
It
I can b contained in :
be i di
A text file (which has a .css suffix)
Embedded within <style> element contained within the
<head> element
Inline within any element via the style= attribute.
4. Why CSS?
4
There are numerous advantages of using CSS
f CSS:
Greater control over textual effects and page layout.
Separates document content (HTML) from its
appearance (CSS).
R d i
Reducing d li i of style commands.
duplication f l d
Increase ease in web site maintenance.
The disadvantages of CSS is:
f
Harder to learn than straight HTML
Some unevenness with browser support
IE prior to vers. 7 in particular has several CSS bugs
5. So why is separating appearance from content so
important?
i ?
5
Currently ( ith t CSS) th vast majority of a given HTML
C tl (without CSS), the t j it f i
document’s markup is devoted to formatting/layout.
These types of documents are very hard to maintain and
change.
Using markup, there is no easy way to replicate a design change
over an entire site
site.
Using markup for layout (i.e., tables) creates fragile and hard to
change layouts.
These documents are not accessible (i.e., not easily usable
by people with visual disabilities).
These documents are hard to index (e.g., by search engines)
(e g
accurately.
Google “is in effect the world’s most active blind user” (Meyer, 3).
Eric Meyer, Cascading Style Sheets, 2nd Ed, (O’Reilly, 2004).
7. Example Problem
7
This page’s content:
Date
Image
News Navigation Links
Link Newsroom
Link Events
Link Media Centre
Link Mount Royal Experts
News & Events
Feature Story
Policy Studies program joins forces with Students' Association to host all-candidates debate
Just days before Canadians cast their votes in our federal election, Mount Royal College will host an all-
all
candidates debate
Link
Image
Caption
Tami Rothery VP Student Life etc
Newsroom
Link
Link
Link
Link
Link
8. HTML for the Content
8
<div id=“news”>
<div id=“newsNavigationLinks”>
<ul>
<li><a href=???>NewsRoom</a></li>
<li><a href=???>Events</a></li>
etc
</ul>
</div>
<p>Date</p>
<img src=???>
<h1>News & Events</h1>
<div id=“story”>
<h2>Feature Story</h2>
y
<img>
<p id=caption>Tami Rothery VP Student Life etc</p>
<p><em>Policy Studies program joins forces with Students' Association
to host all‐candidates debate</em></p>
<p>Just days before Canadians cast their votes in our federal
election, Mount Royal College will host an all‐candidates debate</p>
, y g p
<a href=???>More</a>
</div>
<div id=“newsLinks”>
<h2>Newsroom</h2>
<ul>
<li><a href=???>Current News</a></li>
/ /
<li><a href=???>News Archive</a></li>
etc
</ul>
</div>
</div>
9. Actual HTML (which contains content and presentation)
9
<table width 720 border="0" align="center" cellpadding="0" cellspacing="0" valign="top"><tr><td valign="top" width="620"
<table width="720" border 0 align center cellpadding 0 cellspacing 0 valign top ><tr><td valign top width 620
height="9"><img src="images/spacer.gif" width="620" height="9" border="0"></td></tr><tr><td valign="top" width="620"
height="29"><img src="images/spacer.gif" width="63" height="5" border="0"><script language="JavaScript"><small><font color='white'
face='Arial' size='1'><b>January 11, 2006</b></font></small></td></tr><tr><td valign="top" width="620" height="98"><img
src="images/spacer.gif" width="620" height="98" border="0" alt="News & Events"></td></tr></table></td></tr></table><table
width="720" align="center" cellpadding="0" cellspacing="0" border="0"><tr><td width="100" valign="top" bgcolor="#003399"><a
_ g _ jpg _ g _ jpg g
href="newsroom.php" onMouseOver="document.ne_new.src='images/ne_newr.jpg'" onMouseOut="document.ne_new.src='images/ne_new.jpg'"><img
src="images/ne_new.jpg" alt="Newsroom" title="Newsroom" name="ne_new" border="0"></a><br><a href="events.php"
onMouseOver="document.ne_eve.src='images/ne_ever.jpg'“ onMouseOut="document.ne_eve.src='images/ne_eve.jpg'"> <img
src="images/ne_eve.jpg" alt="Events" title="Events" name="ne_eve" border="0"></a><br>
<a href="mediarelations.shtml" onMouseOver="document.ne_med.src='images/ne_medr.jpg'"
onMouseOut="document.ne_med.src='images/ne_med.jpg'"><img src="images/ne_med.jpg" alt="Media Centre" title="Media Centre"
name="ne_med" border="0"></a><br><a href="experts.php" onMouseOver="document.ne_exp.src='images/ne_expr.jpg'"
onMouseOut="document.ne_exp.src='images/ne_exp.jpg'"> <img src="images/ne_exp.jpg" alt="Mount Royal Experts" title="Mount Royal
Experts" name="ne_exp" border="0"></a></td><td width="35" valign="top"><img src="images/homepage_top1.jpg"></td><td width="550"
valign="top"><font face="arial" size="2"><img src="images/homepage_top2.jpg"><br><table width="550" align="center" cellpadding="0"
cellspacing="0" border="0"><tr><td width="355" valign="top" colspan="3"><img src="images/title_featurestory.jpg" alt="Feature
Story"></td><td width="35" valign="top"><img src="images/featureshadow1.jpg"></td><td width="160" valign="top"><img
src="images/title_newsroom.jpg" alt="Newsroom"></td></tr><tr><td width="355" height="163" valign="top" colspan="3"
background= images/feature_bg.jpg ><table width= 355 align center cellpadding 0 cellspacing 0 border 0 ><tr><td width= 355
background "images/feature bg jpg"><table width "355" align="center" cellpadding="0" cellspacing="0" border="0"><tr><td width "355"
height="12" colspan="5" valign="top"><img src="images/spacer.gif" width="355" height="12" border="0"></td></tr><tr><td width="12"
height="139" valign="top"><img src="images/spacer.gif" width="12" height="139" border="0"></td><td width="147" height="139"
valign="top"><img src="featurestories/images/candidatedebate.jpg" border="0" alt="Tami Rothery, V.P. Student Affairs and Jackie
Chuckrey, SAMRC President overlook the location of the upcoming candidates debate."></td><td width="12" height="139"
valign="top"><img src="images/spacer.gif" width="12" height="139" border="0"></td><td width="171" height="139" valign="top"><font
size 2 face="arial"><strong>Policy Studies program joins forces with Students' Association to host all‐candidates
size="2" face arial ><strong>Policy Studies program joins forces with Students Association to host all candidates
debate</strong></font> <p><font size="1" face="arial">Just days before Canadians cast their votes in our federal election, Mount
Royal College will host an all‐candidates debate... > <a href="featurestories/candidatedebate.shtml">More</a></font></p>
</td><td width="12" height="139" valign="top"><img src="images/spacer.gif" width="12" height="139" border="0"></td></tr><tr><td
width="355" height="12" colspan="5" valign="top"><img src="images/spacer.gif" width="355" height="12"
border="0"></td></tr></table></td><td width="35" valign="top"><img src="images/featureshadow2.jpg"></td><td width="160"
g p g g p g g p p
valign="top"><font face="arial" size="1"><img src="images/spacer.gif" width="160" height="15"><br><a href="newsroom.php">Current
News</a> <img src="images/spacer.gif" width="160" height="5"><br><a href="archive.php">News Archives</a> <img
src="images/spacer.gif" width="160" height="5"><br><a href="/alumni/e_news.shtml">Alumni News</a> <img src="images/spacer.gif"
width="160" height="5"><br><a href="http://cougars.mtroyal.ca/">Cougar News</a> <img src="images/spacer.gif" width="160"
height="5"><br><a href="/conservatory/news.php">Conservatory News</a></font></td></tr></table>
10. Mixing Presentation with Content
10
Combining presentation and content makes the HTML h d
C b d k h harder
to understand and to maintain.
Almost all of this sample consists of position markup (all the table
tags), formatting markup, and gratuitous images (single pixels for
spacing, simple text images for headings).
This little code snippet has 8 font tags: each one made the same
change (white color, font name=Arial and size=small).
The entire page in fact had 20 font tags doing the same thing.
To change to a different color and font and size, we will have to
change 60 attributes in a total of 20 tags.
With CSS
Wi h CSS, we can specify this font rule just once.
if hi f l j
To make the same change we only have to make one change to three
CSS rules.
11. Mixing Presentation with Content
11
In fact the entire main content pages (thousands of pages) of the www.mtroyal.ca site
used to have tens of thousands of font tags, almost all of which were one of the following:
<font face="Arial, Helvetica, sans-serif" size=2>
<font face="Arial, Helvetica, sans-serif" size=1>
<font face="Arial, Helvetica, sans-serif">
<font face "Arial">
face="Arial">
<font size=2>
<font size=1>
<font size=4>
<font face="Arial" size=2 bgcolor=white>
<font face="Arial" size=2 bgcolor=black>
<font face="Arial" size=1 bgcolor=white>
<font face="Arial" size=1 bgcolor=black>
<font face="Arial, Helvetica, sans-serif" size=2 bgcolor=black>
<font face="Arial, Helvetica, sans-serif" size=1 bgcolor=black>
<font face="Arial" size=4 bgcolor=white>
<font face="Arial" size=4 bgcolor=black>
o t ace a s e bgco o b ac
12. Mixing Presentation with Content
12
To k
T make a site-wide change to the font face, size, or
i id h h f f i
color, for www.mtroyal.ca site would take hundreds of
very tedious hours.
y
To change the font used in all the images would again
take hundreds of very tedious hours
If the same site had been designed to separate
presentation from content and to properly structured
that content, the same change would take under a
content
minute.
An entire site can use a single CSS file.
If the CSS is properly cascaded, we would only have to
make a few changes to that one file.
13. What does cascading mean?
13
CSS are considered cascading because the
styles can use a hierarchy which passes styles
down to the elements
elements.
Previously defined styles are applied unless
a new, overriding style change is made.
14. What does cascading mean?
g
body font-face: Arial, Helvetica, sans-serif; color: black;
14
h1 font-size:14pt;
p font-size:10pt;
div id=story font-size:12pt; font-weight: bold;
div id=news background:white;
div id=story position: relative; left: 125px; width: 200px
p font-weight: normal;
15. CSS Rules
15
Style sheets consist of one or more rules.
Each rule defines what an element should look like
and how it should behave in the browser window.
The following contains two rules.
The first indicates that the use of h2 should result in the
text being colored green. The second indicates text in a
b i l d Th d i di i
p tag should be 12pt Arial or some sans-serif font.
h2 { color: green; }
p { font-size: 12pt; font-face: Arial, sans-serif;
}
16. CSS Rule Placement
16
There are three ways in which rules can be applied
to a document:
Inlinestyles
Embedded styles
y
External styles
17. Inline Styles
17
Are added to a tag via the style attribute.
<h2 style="color: green;">
<p style="font-size: 12pt; font-face: Arial, sans-serif;">
Affects only that instance of the tag.
Not recommended
recommended.
18. Embedded Styles
18
Are added in the head of the page and affects all
instance of the defined tag.
<head>
<style type="text/css">
h2 { color: green; }
p { font-size: 12pt; font-face: Arial sans-serif;
Arial, }
</style>
</head>
19. External Styles
19
Are t d in
A stored i an external fil and linked or imported i t a page.
t l file d li k d i t d into
Generally the best approach since a single external stylesheet file
can be used in multiple pages.
They thus provide a way to achieve consistent styling across an entire
site.
Two approaches
pp
Linking
<head>
<link rel="stylesheet" type="text/css" href="styles.css">
</head>
Importing
<style type="text/css">
@import url(styles.css);
@import url(colours.css);
</style>
20. CSS Rule Composition
20
A CSS rule i composed of two parts:
l is d ft t
Selector
Declaration block
The selector defines which part of the document is to be affected.
The declaration block consists of one or more declarations.
Each declaration is separated by semicolons
semicolons.
A declaration is a combination of CSS property and a value for that
property.
Declaration Block
h1 { color: green; font-size: 24pt; }
Selector Declaration property value
21. Document Structure
21
As mentioned, XHTML should describe the structure
and content of the document, while CSS describes
its appearance.
Understanding this XHTML structure is a necessary part
of mastering CSS.
XHTML documents contain a hierarchy of elements
M y
22. Document Structure
22
html
body is an ancestor of img
head body
body is the parent of ul
title link h1 p a ul ul is a child of body
a img li li
img is a descendent of body
23. Selectors
23
Selectors are what connect the style definitions to
the specific tags that are to be modified.
There are three basic forms of selectors:
HTML selectors
Class selectors
ID select
24. HTML Selectors
24
You h
Y have already seen HTML selectors. These are the styles
l d l Th h l
that directly effect an HTML tag element.
h1 { color: red; }
These selectors can also be grouped into comma-separated
lists (this modifies all elements in list).
h2, h3, p { color: blue; }
25. Class Selectors
25
A class selector is used to specify the styles of
elements that have been classified using the class
attribute in the HTML tags.
Theseallow you to define styles independently of the
HTML elements.
period indicating list of property-
st o p ope ty
a class selector value pairs
.classname { property: value; }
name of
class selector
26. Class Selectors Examples
26
An
A HTML element can be classified using the class
l b l ifi d i h
attribute.
The following shows that two tag instances have been
classified as warning tags:
<em class="warning">Do not apply to exposed skin.</em>
<h4 class="warning">Do not induce vomitting.</h4>
<h4 l " i ">D t i d itti </h4>
With these elements classified, we can set up a style
for the class “warning”:
warning :
.warning { font‐size: 36pt; color: red; }
We can also combine HTML and class selectors to
more narrowly target some classes:
b.warning { font size: 36pt; color: red; }
b warning { font‐size: 36pt; color: red; }
h4.warning { font‐size: 48pt; color: red; }
27. Class Selectors
27
You can also specify multiple classes via the class
attribute.
.box {
box { <div class= box a >
<div class="box a">
margin: 10px; <div class="box b">
}
.a {
background: green;
}
.b {
background: red;
}
28. ID Selectors
28
An ID selector is used to target specific instances
(those with the ID) rather than classifying elements
# symbol indicating list of property-
an ID selector value pairs
#idname { property: value; }
name off
ID selector
29. ID Selectors Examples
29
An HTML element can be identified using the id
attribute.
The following shows that this tag instance has been
identified with the value 5511:
<p id="5511">hot sales on now!</p>
With this element identified, we can set up a style for
the id “5511”
h “5511”:
#5511 { font-style: italic; color: blue; }
30. ID Selectors Examples
30
We can also combine HTML and ID selectors.
p#5511 { font‐style: italic; color: blue; }
#5511 { font‐style: italic; color: blue; }
Both of these do the same thing.
The fi t
Th first one is however more self-
i h lf
documenting.
31. Class versus ID selectors
31
Classes can be applied to any number of elements.
Use classes to style a number of different but related
elements.
IDs are used once and only once in an HTML
y
document.
Use ids to style a unique element uniquely.
32. Contextual Selectors
32
There are specialized contextual selectors:
Descendant selectors
Child selectors
Adjacent Sibling selectors
j g
Attribute selectors
33. Contextual Selectors
33
These are rules that operate only in specific
structural or contextual situations.
Forinstance, in the example below, let's change only the
<h2> element within the <div> to green 24pt text.
<div id="logo">
<h1>Pearson Education</h1>
<h2>Book Rep System</h2>
</div>
<h2>Technical Books</h2>
How would we do this?
We could add an id to the specific h2 element (or a class if
we had multiples). However, over time, our markup and css
can become too bloated (and too complicated) with ids and
classes.
34. Descendant Selectors
34
Instead, we could use a contextual selector.
For instance, we could use a descendant selector, which
selects/matches all elements that are descendants of an
element.
<div id="logo">
<h1>Pearson Education</h1>
<h2>Book Rep System</h2>
</div>
<h2>Technical Books</h2>
/
a div that contains a h2
div h2 {color: green; font-size: 24pt; }
h2 is a descendant of the di
div
h2 contained within a div
div is the ancestor of the h2
35. Child Selectors
35
Matches/selects all elements that are immediate
child of a specified element, including elements that
are not direct descendants.
<div id="logo">
<h1>Pearson Education</h1>
<h2>Book Rep System</h2>
</div>
<h2>Technical Books</h2>
/
NOT Supported by IE 6
div>h2 {color: green; font-size: 24pt; } or earlier
h2 is direct child of div
36. Child Selectors
36
<div class="box">
<p>This text will be green</p>
<p>This text will be green as well</p>
<div class="title">
<p>this text will be green as well if we use descendant selector,
<p>this text will be green as well if we use descendant selector
but if we use a child selector it will be red.
</p>
</div>
</div>
<p>What color will I be?</p>
p {
p { color: red; }
; } p { color: red; }
.box p { color: green; } .box>p { color: green; }
b { l }
37. Adjacent Sibling Selectors
37
Selects all elements that are the adjacent (i.e.,
follows immediate) siblings of an element.
<h1>Pearson Education</h1>
/
<p>This is the first</p> Only the first <p> will be
<p>This is the second</p> selected
h1+p {color: green; font-size: 24pt; }
NOT Supported by IE 6
or earlier
p is direct adjacent sibling of h1
38. Attribute Selectors
38
Will match elements on the basis of the presence of
an attribute or a match of the attribute value.
input[type="text"] {
background‐color: yellow;
color: red;
}
NOT Supported by IE 6
or earlier
39. Attribute Selectors
39
<label>Name </label>
<label>Name </label>
<input type="text" /><br/>
<label>Phone </label>
<input type="text" /><br/>
<label>Password </label>
<input type="password" /><br/>
<input type="submit" />
Matches elements that contain that
attribute (regardless of its value)
Matches only elements with a particular
attribute value input[type] {
background‐color: yellow;
color: red;
input[type="text"] { }
background‐color: yellow;
color: red;
}
40. Pseudo Classes
40
Pseudo classes refer to a variety of additional
labels that can be added to a selector based on its
user state.
Indicated via a colon (:)
()
41. Pseudo Classes
41
In CSS 1, only the <a> element supports four
different pseudo-classes
A link that is active, visited, unvisited, or when you
mouse over a link can all be displayed in different
ways.
E.g.
a:link {color: blue;}
a:visited {color: purple;}
a:hover {color: red; text-decoration: none; font-weight:bold; }
a:active {color: olive}
Order of these is important
Link
Link, visited hover active
visited, hover,
43. Selectors Exercise
43
<div id="logo">
<img src="whatever.gif" /> .extra { color: green; }
<p>tagline</p>
</div> div.extra { color: green; }
<div class="header">
<h1>Pearson Education</h1>
<h2>Book Rep System</h2> #logo { color: green; }
<p>Some random text.</p>
<p>here is some more.</p>
</div> div p { color: green; }
p { g ; }
<p>My name is Ishmael.</p>
<p>Some years ago</p> div p:first‐child { color: green; }
<div class="extra">
<p>Some more random text.</p> p { g ; }
h2+p { color: green; }
<h2>Products</h2>
<p>This paragraph will be displayed.</p>
<p>So will this one.</p> h2>p { color: green; }
<div id="subtext">
<p>never mind how long</p>
p g p div>p { color: green; }
p { g ; }
</div>
</div> div[class] { color: green; }
<p class="extra">having little or no money</p>
44. div.extra { color: green; }
.extra { color: green; }
extra { color: green; }
<div id="logo">
<img src="whatever.gif" />
<p>tagline</p>
</div>
<div class="header">
<h1>Pearson Education</h1>
<h2>Book Rep System</h2>
<p>Some random text.</p>
<p>here is some more.</p>
</div>
<p>My name is Ishmael.</p>
<p>My name is Ishmael </p>
<p>Some years ago</p>
<div class="extra">
<p>Some more random text.</p>
<h2>Products</h2>
<p>This paragraph will be displayed.</p
<p>So will this one.</p>
<div id="subtext">
<p>never mind how long</p>
</div>
</div>
<p class extra >having little or no mone
<p class="extra">having little or no mone
44
45. #logo { color: green; }
div p { color: green; }
<div id="logo">
<img src="whatever.gif" />
<p>tagline</p>
</div>
<div class="header">
<h1>Pearson Education</h1>
<h2>Book Rep System</h2>
<p>Some random text.</p>
<p>here is some more.</p>
</div>
<p>My name is Ishmael.</p>
<p>My name is Ishmael </p>
<p>Some years ago</p>
<div class="extra">
<p>Some more random text.</p>
<h2>Products</h2>
<p>This paragraph will be displayed.</p>
<p>So will this one.</p>
<div id="subtext">
<p>never mind how long</p>
</div>
</div>
<p class extra >having little or no money</
<p class="extra">having little or no money</
45
46. div p:first‐child { color: green; }
div p:first‐child { color: green; }
<div id="logo">
h2+p { color: green; }
<img src="whatever.gif" />
<p>tagline</p>
</div>
<div class="header">
<h1>Pearson Education</h1>
<h2>Book Rep System</h2>
<p>Some random text.</p>
<p>here is some more.</p>
</div>
<p>My name is Ishmael.</p>
<p>My name is Ishmael </p>
<p>Some years ago</p>
<div class="extra">
<p>Some more random text.</p>
<h2>Products</h2>
<p>This paragraph will be displayed.</p>
<p>So will this one.</p>
<div id="subtext">
<p>never mind how long</p>
</div>
</div>
<p class extra >having little or no money</
<p class="extra">having little or no money</
46
47. h2>p { color: green; } div>p { color: green; }
<div id="logo">
<img src="whatever.gif" />
<p>tagline</p>
</div>
<div class="header">
<h1>Pearson Education</h1>
<h2>Book Rep System</h2>
<p>Some random text.</p>
<p>here is some more.</p>
</div>
<p>My name is Ishmael.</p>
<p>My name is Ishmael </p>
<p>Some years ago</p>
<div class="extra">
<p>Some more random text.</p>
<h2>Products</h2>
<p>This paragraph will be displayed.</p>
<p>So will this one.</p>
<div id="subtext">
<p>never mind how long</p>
</div>
</div>
<p class extra >having little or no money</p
<p class="extra">having little or no money</p
47
48. div[class] { color: green; }
<div id="logo">
<img src="whatever.gif" />
<p>tagline</p>
</div>
<div class="header">
<h1>Pearson Education</h1>
<h2>Book Rep System</h2>
<p>Some random text.</p>
<p>here is some more.</p>
<p>here is some more </p>
</div>
<p>My name is Ishmael.</p>
<p>Some years ago</p>
<div class="extra">
<p>Some more random text.</p>
<h2>Products</h2>
h d /h
<p>This paragraph will be displayed.</p>
<p>So will this one.</p>
<div id="subtext">
<p>never mind how long</p>
/
</div>
</div>
<p class="extra">having little or no money</p>
48
49. Font Formatting with CSS
49
font formatting properties and possible values
values.
font-family: [family name], [family name], etc
font-size: [height] | [percentage] | small | medium | large | smaller | etc
font-style: italic | oblique | normal
font-weight: normal | bold | bolder | lighter | etc
font-variant: small-caps | normal
font: [font-style]|[font-weight] [font-size][/line-height] [font-family]
50. Font Formatting with CSS
50
The font-family property should always specify a
generic font family name in case the computer
viewing the page does not have one of the
specified fonts. Generic family name
font-family: Arial, Tahoma, sans-serif;
The font property allows you to combine multiple
font styles into one declaration.
font: bold 12pt Arial, Tahoma, sans-serif;
51. Platform Considerations
51
Do not assume that a font you have is one that is on
the viewer's computer.
Fonts
common (for most users) to both Mac and
Windows:
Arial,Arial Black, Arial Narrow, Comic Sans, Courier New
Georgia, Impact, Tahoma, Times New Roman
Trebuchet MS, Verdana
52. CSS Sizes
52
Font sizes (and all CSS sizes) can be specified using
absolute or relative units
Relative
smaller, larger keywords
Percentages
em value
This is the height of the character box for the font
Absolute
small, medium, large, etc keywords.
Inches (in), points (pt), pixels (px), etc.
53. Sizing Fonts
53
Generally, the most common approach is to set the
size in pixels.
h2 { font-size: 18px; }
Advantage is that the designer has complete control
over what the user sees in terms of the size of the font.
Any problems with this?
yp
54. Sizing Fonts
54
Not all users have the same eye strength.
Browsers provide user with ability to resize font size.
Unfortunately, with IE 6 and 7, if the page's CSS uses
pixel unit to set font size then the text will not be
resized.
55. Sizing Fonts
55
It is better to use a relative unit for sizing fonts, even
though it is initially a bit tricky.
Three approaches
Use keywords (x‐small, small, medium, large, etc)
x small, small, medium, large
Unfortunatelynot as much control over ultimate size due to
limited number of sizes.
Use em unit
h2 { font-size: 1.5 em; }
Use percentage size
h2 { font-size: 120%; }
56. Percentage Size
56
This is a percentage of the elements parent's font
size. body { font-size: 10px; }
font size:
#logo { font-size: 150%; }
h2 { font-size: 200%; }
.dwarf { font-size: 75%; }
<body>
<div id="logo">
<h2>Book Rep System</h2> 30px ( (10*2.00)* 1.5 )
</div>
<h2>Technical Books</h2> 20px (10 * 2.00)
<p>Here is some regular text</p> 10px
<p class="dwarf">really small</p> 7.5px (10 * 0.75)
</body>
y
57. Percentage Size
57
Unfortunately, the previous example doesn't allow
resizing due to absolute setting of body font size.
Instead, we should use a relative setting for the
body.y
59. Percentage Size
59
Advantage to this approach is that you can change
the overall size of text in your site by making just
one change: the font-size of the body.
Disadvantage is that it can get quite complicated
g g q p
with percentages and nested elements.
60. Em sizes
60
As an alternative to percentages, you can use em
sizes.
An em unit when used for sizing fonts is relative to the
baseline size of the parent.
If the parent of an element has a font size of 14 pixels,
then 1em is 14 pixels; if the font size is 24 pixels, then
1 em is 24 pixels.
Most browsers have a default font size of 1em
(about 16 pixels).
61. em sizes
61
body { font-size: 1em; }
#logo { font-size: 1.2em; }
h2 { font-size: 1.5em; }
.dwarf { font-size: 0
i 0.75em; }
<body>
<div id="logo">
g
<h2>Book Rep System</h2> 28px ( (16*1.2)* 1.5 )
</div>
<h2>Technical Books</h2> 24px (16 * 1.5)
<p>Here is some regular text</p>
p g p 16px
p
<p class="dwarf">really small</p> 12px (16 * 0.75)
</body>
62. Conclusion: Font Sizes
62
Set the base body font-size relatively (i.e., using
keyword, em, or percentage).
Use percentage or em for all other sizes,
remembering that they are relative to the size set
g y
for the body.
63. Text Formatting
63
text formatting properties and possible values.
text-indent: [length] | [percentage]
letter-spacing: [length] | normal
word spacing:
word-spacing: [length] | normal
text-decoration: none | underline | line-through | overline
line-height: [height] | [percentage] | normal | etc
text-transform: uppercase | l
t t t f lowercase | capitalize | none
it li
text-align: left | center | right | justify
vertical-align: middle | bottom | top | etc
Just as with font sizes, you should use relative units
(percentage or em) for lengths.
64. Block Level Inline Level
Block-Level vs Inline-Level elements
64
Block-level elements
Generate an element box that fills its parent element's
content area.
That is, they generate "breaks" before and after the
element box.
E.g. <p>, <div>, <ul>, <table>
Inline-level elements
Generate an element box within a line of text
text.
E.g., <a>, <span>, <strong>
65. Element Boxes
65
CSS assumes that every element generates a
rectangular box called the element box (sometimes
also called the box model).
Each element box has
a content area,
a background color and/or image
image,
a margin,
a possible b d
ibl border
internal padding.
66. Element Boxes
66
CSS assumes that every HTML element exists in a
rectangle called the element box.
Background image
and/or color
margin
g border
padding
This is a content area. CSS assumes that every HTML
element exists in a rectangle called the element box.
height
width
Element box
67. Element Box
67
Molly Holzschlag,”Thinking Outside the Grid”, http://www.alistapart.com/articles/outsidethegrid
68. Element Box
68
You can adjust the following parts of the box with
CSS
Width and Height
Border
Thickness, style, and color of the border
Margin
g
Setthe distance between the box and adjacent element's
boxes
Padding
Set the distance of the content from the border of the box
69. Width and Height
69
You can change the width and height of the element
box in quite a few different ways.
The most straightforward way is via the width and
height properties
H1 { width: 50%; height: 25px; }
Remember, the width and height properties set the
size of the content area, not the element box itself.
i f th t t t th l t b it lf
margin
p
padding
g
This is a content area. CSS assumes that every HTML
element exists in a rectangle called the element box.
height
width
70. Width and Height
70
Unfortunately, the width and height properties have
a different meaning in CSS standard than in IE 5 or
IE 6 in quirks mode.
Recall that unless you have a valid DOCTYPE specifying
xhtml strict or xhtml transitional DTD, IE will display
document in quirks mode.
For IE in quirks mode, width and height refer to the
element box not to the content area.
71. Border
71
Can specify each axis individually, e.g.
border-top-style: dashed;
border left color:
border-left-color: red;
border-right-width: 5px;
Can specify all 4 axis at once identically, e.g.
p y y, g
border-style: solid;
border-color: green;
Can
C specify multiple axis at once i di id ll e.g.
if li l i individually,
border-width: 2px 3px 4px 5px; TOP
p p
property: top right bottom left
y p g TRouBLe left right
border-color: green red; green red green red
bottom
Can also specify multiple properties at once
border: 1px double green;
border: width style color;
72. Padding
72
The space between the border and the content area
Can specify each side individually or all at once, e.g.,
padding-top: 5px; TOP
padding: 3px 2px 5px 4px; left right
Default is no padding bottom
If you have a border on box containing text, it is a good
idea to add padding
padding.
73. Margins
73
Margins provide separation between element boxes
Can specify each side individually or all at once,
p y y ,
e.g.,
margin-top: 5px;
margin: 3px 2px 5px 4px;
74. Margin Demo
<h1>Margin demo</h1>
74 <p>Cascading Style Sheets (CSS) is the W3C-approved
method for specifying and enriching the visual
presentation of web pages.</p>
i f b /
<p>CSS is not HTML but does enhance HTML by allowing
you to redefine how pre-existing tags work. A style
sheet is written according to the grammar defined in
the W3C CSS 1 or CSS 2 recommendations. </p>
<style>
* { border: 1px solid black; }
</style>
<style>
* { border: 1px solid black; margin: 0; }
</style>
76. Collapsing Margins
76
For adjacent vertical block-level elements in the
normal document flow, only the margin of the
element with the largest margin value will be
honoured,
while the margin of the element with the smaller margin
value will be collapsed to zero.
77. Collapsing Margins <div>before</div>
<p>line one</p>
<p>line two</p>
77 <p>line three</p>
<div>after</div>
<style>
div { border: 1px solid black; margin: 0;}
p { background-color: silver; height: 50px;
margin-top: 50px; margin-bottom: 0px;}
</style>
<style>
div { border: 1px solid black; margin: 0;}
p { background-color: silver; height: 50px;
margin-top: 50px; margin-bottom: 20px;}
</style>
Notice that vertical margins collapse!!!
o a a ag o ap
When top and bottom margins meet
they overlap until one of the margins
touches the border of the other element
element.
78. Collapsing Margins
78
.box {
margin: 10px;
<div class="box a">
}
<div class="box b">
.a {
<div class="box c">
background: #777;
<div class="box d">
}
<div class="box e">
.b {
b {
The top and bottom margins collapse but the left and
background: #999;
right margins don't. The top and bottom margins also
}
collapse in IE 7 because the elements don't have a
.c {
layout.
background: #bbb;
</div>
}
</div>
.d {
.d {
</div>
background: #ddd;
</div>
}
</div>
.e {
background: #fff;
}
Tommy Olsson & Paul O’Brien, The Ultimate CSS Reference (SitePoint, 2008).
79. Collapsing Margins
79
You can stop vertical margins collapsing by adding
a border or padding.
.box {
margin: 10px;
padding: 1px;
}
80. Collapsing Margins
80
However, IE 7 will NOT collapse margins if the
collapsed element has layout (i.e., has a width
setting).
.box {
margin: 10px;
width: 400px;
}
Firefox
IE 7
81. Collapsing Margins
81
Also, margins don’t collapse (in all browsers) for:
floated elements
absolutely positioned elements
inline-block elements
cleared elements
overflow set to anything other than visible
83. Can I just forget IE 7 (and 6)?
83
http://stats.wikimedia.org/wikimedia/squids/SquidReportClients.htm
http://www.statowl.com/web_browser_market_share.php?mes=ndd
84. Element box size revisited
84
Recall that in CSS standard, the width and height
properties set the size of the content area, not the
element box itself.
Any p
y padding or borders increases the size of the
g
element box
However,
However with IE in quirks mode (or version 5) the
5),
width and height indicate the size of the element
box.
box
Padding and borders thus shrinks the size of the content
area.
85. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> IE in quirks mode
<style>
p { background-color: silver;
height: 100px; width: 100px; } 100px 100px
</style>
100px 100px
<style>
p { background-color: silver;
height: 100px; width: 100px;
padding: 20px; }
</style> 140px 100px
100px
100
140px
<style>
p { background-color: silver;
height: 100px; width: 100px;
padding: 20px; 100px
border: 6px solid black; } 152px
/ y
</style>
85 100px
152px
86. Containing Boxes
86
Block boxes act as a containing block for any
boxes within them.
<div>
This is the first sentence.
<p>This is the second sentence.</p>
</div>
In this code, the div element establishes a containing
, g
block for both the first string of text and the P
element.
The p element in turn creates a containing block for
the second text string
string.
87. Positioning
87
You can change the position of an element box via
the position, top, left, bottom, and right properties.
Note: it doesn’t make sense to set both left and right.
Note: it doesn’t make sense to set both top and bottom.
88. Positioning Property Values
88
static
Eachposition is laid out based on the normal flow of the
document (default)
relative
Moves an element relative to its normal (static) position.
absolute
Moves an element absolutely relative to its containing block,
y g ,
and not relative to the page or window.
fixed
Moves an element absolutely relative to the browser window
so that the element never moves, even when the page is
scrolled (not supported in IE 6 or lower).
This can be used to replicate HTML frames in CSS
89. Static Positioning
89
Element boxes flow vertically starting at the top
of their containing block with each placed
directly below the preceding one.
Inline boxes flow horizontally from left to right.
90. Positioning
90
positioned elements are placed in relation to their
d l l d l h
containing blocks (but are not confined by this
containing block)
block).
Fixed
Containing block is browser window
Absolute
Containing bo is closest positioned ancestor
box ancestor.
If there is no positioned ancestor, the initial containing block
is the browser window.
Relative
Does not have a containing block.
It is positioning away from its normal (static) position.
91. <style type="text/css">
#logo {
border: 1
1px solid black; width: 300
i i 300px;
position: relative; top: 200px; left: 100px; }
</style>
<body> <body>
<div id="logo"> You can change the position of an element …
<h1><span>Pearson Education</span></h1> You can change the position of an element …
<h2><span>Book Rep System</span></h2> You can change the position of an element …
</div> <div id="logo">
</body> <h1><span>Pearson Education</span></h1>
<h2><span>Book Rep System</span></h2>
</div>
</body>
91 Remember that relative moves an element relative to its normal position
92. <style type="text/css">
#logo {
border: 1
1px solid black; width: 300
i i 300px;
position: absolute; top: 200px; left: 100px; }
</style>
<body> <body>
<div id="logo"> You can change the position of an element …
<h1><span>Pearson Education</span></h1> You can change the position of an element …
<h2><span>Book Rep System</span></h2> You can change the position of an element …
</div> <div id="logo">
</body> <h1><span>Pearson Education</span></h1>
<h2><span>Book Rep System</span></h2>
</div>
</body>
92
93. <body>
<div id="logo">
<h1><span>Pearson Education</span></h1>
<h2><span>Book Rep System</span></h2>
</div>
</body>
<style type="text/css">
#logo {
border: 1px solid black;
width: 300px; height: 100px;
position: absolute; top: 200px; left: 100px; }
#logo h2 {
position: absolute; top: 20px; left: 100px; }
</style>
<style type="text/css">
y yp
#logo {
border: 1px solid black;
width: 300px; height: 100px;
position: absolute; top: 200px; left: 100px; }
#logo h2 {
position: relative; top: 20px; left: 100px; }
</style>
Remember that absolute moves an element absolutely relative to its containing block, and
93 not relative to the page or window.
94. <body>
<div id="logo">
<h1><span>Pearson Education</span></h1>
<h2><span>Book Rep System</span></h2>
</div>
</di >
</body>
100px
20px
<style type="text/css">
#logo {
border: 1px solid black;
width: 300px; height: 100px;
position: absolute; top: 200px; left: 100px; }
#logo h2 {
position: absolute; top: 20px; left: 100px; }
</style>
Remember that absolute moves an element absolutely relative to its containing block, and
94 not relative to the page or window.
95. 20px
100px
<style type="text/css">
#logo {
border: 1px solid black;
p ;
width: 300px; height: 100px;
position: absolute; top: 200px; left: 100px; }
#logo h2 {
position: absolute; top: 20px; left: 100px; }
</style>
<style type="text/css">
#logo { <body>
border: 1px solid black; <div id="logo">
<h1><span>Pearson Education</span></h1>
width: 300px; height: 100px; <h2><span>Book Rep System</span></h2>
h2 B k R S t / /h2
} </div>
#logo h2 { </body>
position: absolute; top: 20px; left: 100px; }
</style>
Remember that absolute moves an element absolutely relative to its containing block, which is closest
95 positioned ancestor; if none, then container is browser window.
96. 100px
20px
<style type="text/css"> Without #logo h2 positioning
#logo {
#l
border: 1px solid black;
width: 300px; height: 100px;
position: absolute; top: 200px; left: 100px; }
#logo h2 {
position: relative; top: 20px; left: 100px; } <body>
</style> <div id="logo">
<h1><span>Pearson Education</span></h1>
<h2><span>Book Rep System</span></h2>
</div>
</body>
y
96 Remember that relative moves an element relative to its normal position
97. Positioning
97
Absolute positioning is sometimes used to position an
element off-screen.
An example is the click to skip navigation link added for
screen readers.
98. Floats
98
Floating is achieved by setting the float property on
an element's style to either left or right.
Non-floated content will flow along the side
opposite to the specified float direction.
pp p
.image { float: left; }
No float .image { float: right; }
<img src="images/pic.gif" class="image" />
<p>
Floated boxes will move to the left or right until …
</p>
99. Clearing Floats
99
Block-level elements will continue to wrap around
floated element for the entire height of floated
element.
100. Clearing Floats
100
The CSS property clear forces an element to
display beneath any floated elements.
No clear
.clear {
clear: both;
;
}
<img src="images/pic.gif" class="image" />
<p>Float boxes …
<p class="clear">Floating an image …
101. Clear
101
clear: l f
l left
The element is moved below the bottom outer edge of any
left-floating boxes that resulted from elements earlier in the
g
source document.
clear: right
The element is moved below the bottom outer edge of any
right-floating boxes that resulted from elements earlier in
the source document.
clear: both
The element is moved below all floating boxes of earlier
elements in the source d
l i h document.
clear: none
102. Floats
102
Floated boxes will move to the left or right until
their outer edge touches the containing block edge
or the outer edge of another float.
<div id="logo">
<img src="images/pic.gif" class="image" />
<p>
Floated boxes will …
</p>
</div>
#logo { margin: 50px; border: 1px solid black;}
div p {background‐color: yellow; border: 1px dashed black; }
.image { float: left; }
103. Floating Left and Right
103
You can float items in a container both left and
right.
.leftImage { float: left; }
.rightImage { float: right; }
<img src= images/pic.gif class="leftImage" />
<img src="images/pic gif" class= leftImage />
<img src="images/pic.gif" class="rightImage" />
104. Floating Left and Right
104
Once you’ve floated all the elements within a
container, that container will no longer have any
non-floated content, so the container will collapse to
zero height.
Notice no background color
<div id="logo">
#logo { margin: 50px;
<img src="images/pic.gif" class="leftImage" />
border: 1px solid black;
<img src="images/pic.gif" class="rightImage" />
background‐color:yellow; }
</div>
105. Floating Left and Right
105
To avoid this problem, set an explicit height for the
containing block.
#logo { margin: 50px;
height: 120px;
border: 1px solid black;
background‐color:yellow; }
106. Multi Column
Multi-Column Layouts
106
Two approaches for creating multi-column layouts:
Using floats
Using positioning
Note: this refers to how the basic multi-column
multi column
layout is created.
One might still use floats (for other elements, such as a
elements
header) within a layout created via positioning.
107. Multi Column
Multi-Column Layouts
107
A complicated float-based layout:
canbe tricky and fragile (esp. in IE before version 8).
Hard to preserve source-order (see next slide).
A complicated position-based layout:
position based
has fewer problems with IE
it i really t
is ll troublesome to di l a f t b l th
bl t display footer below the
columns.
108. Source Order
108
refers to how page elements are arranged, or
ordered in the source.
This is important for:
accessibility
reasons
SEO (Search Engine Optimization)
We want the page s content to appear in the markup
page’s
before things like secondary navigation columns.