Computer Science  ·  Level 6
Web Designing
Chapter 4: Styles
📚 3 Topics
⚑ What you will be able to do

By the end of this chapter, you will be able to:

  • Choose the best style concepts to make web pages look great and work well.
  • Apply internal CSS styles correctly inside an HTML document to control the page’s appearance.
  • Create an external CSS file properly to keep your web page styles organized and easy to update.

Mastering these skills helps you build professional, attractive websites that are easy to maintain and impress users.

Styles in web design form the foundation of how content is presented and perceived by users, shaping the overall user experience. In Kenya's fast-growing digital economy, web designers in sectors such as fintech, e-government portals, and e-learning platforms must master style concepts to create visually appealing, accessible, and consistent websites. These style principles govern the use of backgrounds, spacing, alignment, and borders, which collectively influence readability, navigation, and aesthetic appeal. Understanding these concepts is crucial for Computer Science professionals tasked with developing user interfaces that meet both functional and branding requirements.

4.1 Style Concepts

Style concepts in web design refer to the visual and spatial properties applied to webpage elements that determine their appearance and layout. These include the use of backgrounds, padding, alignment, and borders, each playing a distinct role in enhancing user engagement and usability. Kenyan software developers working on platforms like county government websites or online banking portals rely on these style properties to create interfaces that are intuitive and visually coherent across diverse devices and screen sizes.

4.1.1 Background

The background of a webpage or an element sets the visual context against which content is displayed. It influences the mood, brand identity, and legibility of the content. In Kenya’s digital public services, for example, appropriate background usage can enhance accessibility for users with varying visual abilities.

Role of Background in Web Design

  • Visual Context: The background provides a canvas that can complement or contrast with foreground elements, affecting how users perceive the content. For instance, a light background with dark text improves readability on government information portals.
  • Brand Identity: Background colors or images often reflect organizational branding. A SACCO website may use its brand colors as backgrounds to reinforce recognition and trust.
  • User Engagement: Dynamic or interactive backgrounds, such as subtle animations, can enhance user engagement but must be balanced to avoid distraction on educational platforms.
  • Accessibility: Proper background contrast is essential for users with visual impairments. For example, Kenya’s Ministry of Health websites ensure backgrounds meet WCAG contrast standards to support all users.
  • Performance Considerations: Large background images can increase page load times, negatively impacting user experience in regions with slow internet connectivity such as rural areas.

Types of Backgrounds

  • Solid Color: A single, uniform color used as a background, often chosen for simplicity and clarity. For instance, a banking portal may use a solid blue background to convey professionalism.
  • Gradient: A gradual blend between two or more colors that adds depth and modern aesthetics, popular in tech startups’ websites.
  • Image Backgrounds: Photographic or graphic images used as backgrounds to create a thematic or atmospheric effect, such as tourism boards showcasing landscapes.
  • Patterned Backgrounds: Repeating designs or textures that can subtly enhance visual interest without overwhelming content, used in creative agencies’ portfolios.
  • Video Backgrounds: Short looping videos as backgrounds to create dynamic, immersive experiences. These are rare in Kenya due to bandwidth constraints but increasingly used on corporate homepages.

Implementing Backgrounds in CSS

  • background-color: Defines the solid color behind an element.
  • background-image: Specifies an image to use as a background.
  • background-repeat: Controls whether the background image repeats horizontally/vertically.
  • background-position: Sets the starting position of the background image.
  • background-size: Determines how the background image scales (e.g., cover, contain).

Challenges in Background Design and How to Overcome Them

Challenges
  • Low Contrast: Using backgrounds that reduce text readability.
  • Performance Impact: Large images or videos slowing down page load.
  • Device Compatibility: Backgrounds not displaying correctly on different screen sizes.
  • Distracting Elements: Overly complex or animated backgrounds diverting attention.
  • Cultural Sensitivity: Background images or colors inappropriate for certain Kenyan communities.
Overcoming Challenges
  • Use high-contrast color combinations tested with tools like WebAIM.
  • Optimize images using compression tools to reduce file size.
  • Employ responsive design techniques to adapt backgrounds on mobile devices.
  • Limit animations and use subtle effects to maintain focus.
  • Consult local cultural norms when selecting imagery and colors.

4.1.2 Padding

Padding is the space between the content of an element and its border or edge, crucial for creating whitespace that improves readability and user interface clarity. In Kenyan e-commerce platforms, proper padding ensures product descriptions and images do not appear cluttered, enhancing user experience and encouraging transactions.

Purpose of Padding in Layout Design

  • Content Separation: Padding creates a buffer zone around content, preventing it from touching borders or other elements.
  • Visual Comfort: Adequate padding reduces eye strain by avoiding cramped text or images.
  • Hierarchy and Structure: Differentiates various sections by spacing, aiding navigation on complex sites like online learning portals.
  • Touch Target Expansion: In mobile apps used by farmers, padding enlarges clickable areas, reducing input errors.
  • Consistent Appearance: Uniform padding across a site maintains a polished and professional look.

Padding Properties in CSS

  • padding-top: Space above content.
  • padding-right: Space to the right of content.
  • padding-bottom: Space below content.
  • padding-left: Space to the left of content.
  • padding: Shorthand property to set all four sides simultaneously.

Padding Versus Margin

  • Padding: Space inside an element, between content and border.
  • Margin: Space outside an element, separating it from other elements.
  • In Kenyan government portals, correct use of padding and margin ensures content blocks are distinct yet cohesive.

Best Practices for Padding in Responsive Design

  • Use relative units like em or % to allow padding to scale with screen size.
  • Avoid excessive padding on small devices to maximize usable screen space.
  • Test padding on various devices prevalent in Kenya, including feature phones and low-end smartphones.
  • Combine padding with flexible grid layouts for adaptive spacing.
  • Use CSS media queries to adjust padding dynamically based on viewport width.

4.1.3 Alignment

Alignment determines the positioning of text and other elements within their containers, influencing readability and visual flow. For Kenyan online news portals, proper alignment helps organize dense information clearly, guiding readers through headlines, articles, and advertisements.

Types of Alignment in Web Design

  • Left Alignment: Default for most languages, aligns content to the left edge, ideal for body text on educational websites.
  • Right Alignment: Aligns content to the right edge, useful for dates or metadata on financial reports.
  • Center Alignment: Positions content centrally, often used for headings or call-to-action buttons on retail sites.
  • Justified Alignment: Stretches text to align both left and right edges, common in formal publications online but may cause uneven spacing.
  • Vertical Alignment: Aligns content vertically within containers, important for layout consistency in dashboards.

CSS Properties for Alignment

  • text-align: Controls horizontal alignment of inline content.
  • vertical-align: Controls vertical alignment within inline or table-cell elements.
  • margin auto: Used to center block elements horizontally.
  • flexbox alignment: Properties like justify-content and align-items for flexible layouts.

Impact of Alignment on User Experience

  • Improves readability by organizing content predictably.
  • Enhances aesthetic appeal by balancing whitespace.
  • Guides user focus to important elements like forms or notifications.
  • Supports multilingual websites by adjusting alignment for languages like Swahili (left-to-right) or Arabic (right-to-left).
  • Reduces cognitive load by creating familiar visual patterns.

Alignment Challenges and Solutions

Challenges
  • Misaligned elements causing visual clutter.
  • Inconsistent alignment across pages affecting brand image.
  • Difficulty aligning elements in responsive layouts.
  • Conflicts between text alignment and images or icons.
  • Accessibility concerns with non-standard alignments.
Solutions
  • Use CSS frameworks like Bootstrap that enforce consistent alignment.
  • Employ grid and flexbox systems for responsive alignment.
  • Conduct cross-browser testing to ensure uniform display.
  • Align images and text within the same container carefully.
  • Follow WCAG guidelines to maintain accessibility standards.

4.1.4 Border

Borders define the edges of an element, providing visual separation and emphasis. In Kenyan banking websites, borders delineate form fields and buttons, improving usability and guiding users through transaction processes.

Functions of Borders in Web Design

  • Separation: Distinguishes elements such as menus, content blocks, or forms.
  • Emphasis: Highlights important areas, like featured products or alerts on e-commerce sites.
  • Decoration: Enhances aesthetics with style variations like rounded corners or shadows.
  • Feedback: Changes in border style can indicate interaction states, e.g., focus on input fields.
  • Structural Clarity: Helps organize content hierarchically on complex dashboards.

CSS Border Properties

  • border-width: Thickness of the border.
  • border-style: Defines the line type (solid, dashed, dotted, double, none).
  • border-color: Sets the color of the border.
  • border-radius: Rounds the corners of borders.
  • border shorthand: Combines width, style, and color into one property.

Types of Borders and Their Uses

  • Solid Borders: Most common, used for clear separation.
  • Dashed/Dotted Borders: Used for less prominent separation or decorative purposes.
  • Double Borders: Creates emphasis, often in headers or footers.
  • Inset/Outset Borders: Creates 3D effects for buttons or panels.
  • No Border: Used where minimalism or open design is preferred.

Border Styling Challenges and Remedies

Challenges
  • Overuse resulting in cluttered interfaces.
  • Borders that do not scale well on different devices.
  • Poor color contrast diminishing visibility.
  • Inconsistent border widths breaking design harmony.
  • Borders interfering with adjacent elements in responsive layouts.
Remedies
  • Use borders sparingly and purposefully.
  • Employ relative units for border width where appropriate.
  • Test color contrast against background and content.
  • Maintain consistent border styles across the website.
  • Utilize CSS box-sizing to manage element sizing with borders.

Practice Questions

  1. Explain five key roles of backgrounds in web design and provide examples relevant to Kenyan digital platforms. (10 marks)
  2. Differentiate between padding and margin, highlighting their importance in responsive web design. (8 marks)
  3. Describe four types of alignment used in web design and discuss their impact on user experience in Kenyan online news portals. (12 marks)
  4. List and explain five functions of borders in web design, illustrating how they improve usability in banking websites. (10 marks)
The rest of this chapter
🔒

Create a free account to open more of this chapter.

Free: practical guides, quick cards, workplace scenarios and more.

Create a free account
🔒4.2 Application of Internal Styles

In web design, internal styles provide a method to apply CSS rules directly within an HTML document, facilitating tailored and immediate styling adjustments for a specific webpage. For Computer Science professionals in Kenya working on projects such as univers…

🔒4.3 Creation of External CSS File

External CSS files are essential in professional web development, allowing styles to be defined in separate .css files linked to multiple HTML documents. This approach is particularly important for Kenyan Computer Science professionals managing large-scale app…

Chapter Summary

This chapter explored fundamental style concepts essential for effective web design, beginning with the background property which controls the visual backdrop of elements. It then examined padding, explaining how it creates space between content and element borders to enhance readability and layout. The discussion on alignment covered techniques to position text and elements within a page for visual balance and user engagement. Border styling was addressed, showing how borders frame content and contribute to the overall design aesthetic. The chapter also detailed the application of internal styles, demonstrating how CSS rules can be embedded directly within an HTML document to control presentation. Finally, it introduced the creation of external CSS files, emphasizing their role in separating style from content and enabling consistent design across multiple web pages. Together, these topics provided a comprehensive foundation for styling web pages effectively.

Self-Assessment

🔒 PDFDownload this self-assessment, with answers

A. Written Assessment

  1. What is the purpose of the CSS background property in web design? (2 marks)
  2. Identify the CSS property used to create space between the content and the border of an element. (1 mark)
🔒20 more in this section.

Chapter Examination Questions

🔒 PDFDownload these examination questions, with worked answers

SECTION A (40 Marks) - Answer ALL Questions

  1. Explain the role of background styles in enhancing user experience on a corporate website for a Nairobi-based bank. (4 marks)
  2. Describe how padding affects the layout of content within a web page and why it is important for readability. (4 marks)
🔒18 more in this section.

Chapter Practical Activities

Practical 1: Apply Background Styles to a Webpage Using Internal CSS

Computer Science · Level 6
Web Designing
PRACTICAL ASSESSMENT
TIME: 4 HOURS
⬇ PDFCandidate Instructions (Candidate Tool)

Type: Individual

INSTRUCTIONS TO CANDIDATE:
1.  You are required to perform the following task:
i.  Create an HTML webpage 1024px wide by 768px high applying internal CSS to style the background with at least two different background colors and two background images as per the client specifications.
2.  You have been provided with the following resources for the practical task:
Tools & EquipmentMaterials
Computer with text editorDigital images (JPEG or PNG)
Web browserPlain paper
⬇ PDFResources Required (Cutting List)
S/NItemQuantity
1Computer with text editor and web browser1 Pc per Candidate
2Digital images (JPEG or PNG format, at least 800x600 pixels)2 Images per Candidate
3Plain paper for sketching layout1 Sheet per Candidate
⬇ PDFAssessor Guide
Items to be EvaluatedMarks AvailableMarks ObtainedComments
TASK 1: Create HTML Structure and Apply Internal CSS
Launched text editor and created a new HTML file
(Award 2 marks for launching and file creation)
2
Added HTML5 doctype and basic structure (html, head, body tags)
(Award 3 marks for correct HTML5 structure)
3
Created a container div with width 1024px and height 768px
(Award 3 marks for correct container sizing)
3
Applied internal CSS style tag within the head section
(Award 2 marks for correctly adding <style> tag)
2
Applied at least two different background colors to different sections or elements
(Award 5 marks for correct background-color usage)
5
Applied at least two different background images using internal CSS with appropriate properties (repeat, size, position)
(Award 5 marks for correct background-image usage)
5
Ensured background images display properly within container without distortion
(Award 3 marks for image display correctness)
3
Saved and previewed the webpage correctly in a web browser
(Award 2 marks for successful preview)
2
Sub-Total25
PRODUCT CHECKLIST
Webpage container matches specified size of 1024px width and 768px height
(Award 5 marks for correct container dimension)
5
At least two distinct background colors applied correctly to separate areas
(Award 5 marks for correct background color application)
5
At least two distinct background images applied with correct CSS properties
(Award 5 marks for correct background image application)
5
Background images are clear, properly sized, and positioned without overlapping incorrectly
(Award 5 marks for proper image display and positioning)
5
Sub-Total20
GRAND TOTAL45
ASSESSMENT OUTCOME:   ☐ Competent    ☐ Not Yet Competent (competent if at least 50%)

Practical 2: Set padding for webpage elements using internal CSS

Computer Science · Level 6
Web Designing
PRACTICAL ASSESSMENT
TIME: 4 HOURS
⬇ PDFCandidate Instructions (Candidate Tool)

Type: Individual

INSTRUCTIONS TO CANDIDATE:
1.  You are required to perform the following task:
i.  Create an HTML file named 'padding.html' containing at least three different HTML elements with specified internal CSS padding values: 10px, 20px, and 30px respectively.
2.  You have been provided with the following resources for the practical task:
Tools & EquipmentMaterials
Functional computer with text editor and web browserPlain paper
⬇ PDFResources Required (Cutting List)
S/NItemQuantity
1Functional computer with text editor and web browser1 Pc per Candidate
2Plain paper1 Sheet per Candidate
⬇ PDFAssessor Guide
Items to be EvaluatedMarks AvailableMarks ObtainedComments
TASK 1: Create HTML structure and apply internal CSS padding
Launched text editor and created a new HTML file named 'padding.html'
(Award 2 marks for correct file creation and naming)
2
Added at least three different HTML elements (e.g., div, p, section) in the body
(Award 1 mark for each correct element up to 5 marks)
5
Declared internal CSS style block within the <head> section
(Award 3 marks for correctly placing internal CSS style block)
3
Applied padding of 10px to the first HTML element
(Award 3 marks for correct CSS syntax and value)
3
Applied padding of 20px to the second HTML element
(Award 3 marks for correct CSS syntax and value)
3
Applied padding of 30px to the third HTML element
(Award 3 marks for correct CSS syntax and value)
3
Saved the file and previewed the webpage in a browser
(Award 1 mark for successful preview)
1
Sub-Total20
PRODUCT CHECKLIST
HTML file 'padding.html' contains three distinct elements each with padding set to 10px, 20px, and 30px respectively
(Award 5 marks for each correct padding value applied to the respective element)
15
Sub-Total15
GRAND TOTAL35
ASSESSMENT OUTCOME:   ☐ Competent    ☐ Not Yet Competent (competent if at least 50%)
🔒

Free: practical guides, quick cards, workplace scenarios and more.

Create a free account
🔒Align text and block elements on a webpage using internal CSS stylesPractical 3
🔒Style webpage elements with borders using internal CSSPractical 4
🔒Implement Internal CSS Styles in a WebpagePractical 5
🔒Create and Link an External CSS File to Style an HTML DocumentPractical 6
🔒Design a Webpage Section with Background and Padding StylesPractical 7
🔒Style HTML Elements with Borders and Alignment Using Internal CSSPractical 8
🔒Develop a Horizontal Navigation Menu with Internal CSS StylingPractical 9
🔒Build a multi-section webpage styled with external CSSPractical 10
Flashcards 20 cards Study deck ▾
Question
1

↻ Tap card to reveal answer
🔒

18 more in this section.

Create a free account
Test Yourself 18 questions Start quiz ▾
0%
0 / 2
🔒

16 more in this section.

Create a free account
Am I competent?

At the start of this chapter we promised you would be able to:

  • Choose the best style concepts to make web pages look great and work well.
  • Apply internal CSS styles correctly inside an HTML document to control the page’s appearance.
  • Create an external CSS file properly to keep your web page styles organized and easy to update.

Tick each one you can genuinely do.

So, are you there yet?

You're competent when you can confidently do 50% or more of what this chapter promised.

Sign in to record how you're doing.