Search Header Logo
cse 309 html and css _part2_summer2024

cse 309 html and css _part2_summer2024

Assessment

Presentation

Computers

University

Practice Problem

Medium

Created by

Dr. Rahman

Used 5+ times

FREE Resource

61 Slides • 22 Questions

1

media

2

There are three main ways to incorporate CSS into HTML documents:

  1. Inline CSS

  2. Internal CSS

  3. External CSS

3

Internal CSS

  • Internal CSS styles are defined within the <style> tag located in the <head> section of your HTML document.

  • Styles are applied to elements throughout the HTML document based on selectors.

  • Maintains code separation from HTML content for better organization.

  • Limited reusability across multiple HTML pages.

4

Internal CSS

Example:
<head>

<style>

p {

color: blue;

font-size: 14px;

}

</style>

</head>

5

  • Not reusable across multiple HTML files

  • Can make the HTML file larger

Disadvantages

  • Styles are centralized within the HTML file

  • Easier to maintain compared to inline CSS

Advantages

Internal CSS

6

Inline CSS

  • Inline CSS applies styles directly to HTML elements using the style attribute.

  • Offers granular control over individual elements.

  • Ideal for quick style adjustments or unique element formatting.

  • Increases HTML file size and reduces code readability for extensive styling.

  • Example:

    <p style="color: blue; font-size: 14px;">This is a paragraph.</p>

7

  • Harder to maintain

  • Not reusable

Disadvantages

  • Quick to apply styles directly within HTML

  • Useful for small changes or testing

Advantages:

Inline CSS

8

External CSS

  • External CSS styles reside in a separate CSS file linked to your HTML document using the <link> tag in the <head> section.

  • Promotes code reusability – a single CSS file can style multiple HTML pages.

  • Enables easier maintenance and centralized style management.

  • Requires additional setup for linking the CSS file.

9

External CSS

p {

color: blue;

font-size: 14px;

}

CSS

<head>

  <link rel="stylesheet"
href="styles.css">

</head>

HTML

10

External CSS

Requires an extra HTTP request to load the CSS file

Disadvantages

  • Reusable across multiple HTML files

  • Keeps HTML files cleaner and smaller

  • Easier to maintain and update styles

Advantages

11

Multiple Choice

If you have Inline CSS, Internal CSS, and External CSS all applying styles to the same HTML element, which of the following is the correct order of precedence from highest to lowest?

1

a) External CSS > Internal CSS > Inline CSS

2

b) Inline CSS > Internal CSS > External CSS

3

c) Internal CSS > External CSS > Inline CSS

4

d) External CSS > Inline CSS > Internal CSS

12

Multiple Choice

What is an advantage of using External CSS?

1

a) It requires less maintenance compared to other types of CSS.

2

b) It does not require any additional HTTP requests.

3

c) It keeps HTML files larger and more complex.

4

d) It allows styles to be reused across multiple HTML files.

13

Multiple Choice

Which of the following is an advantage of using Inline CSS?

1

a) It keeps the HTML file cleaner.

2

b) It is reusable across multiple HTML files.

3

c) It allows for quick style application directly within the HTML.

4

d) It requires an extra HTTP request.

14

Multiple Choice

Which type of CSS would you use to apply a consistent style across multiple HTML documents?

1

a) Inline CSS

2

b) Internal CSS

3

c) External CSS

4

d) Embedded CSS

15

Multiple Choice

Which of the following is a feature of External CSS?

1

a) Styles are applied directly to HTML elements using the style attribute.

2

b) Styles are defined within a <style> tag in the <head> section of the HTML document.

3

c) Styles are stored in a separate .css file and linked to the HTML document.

4

d) Styles can only be used for a single HTML file.

16

Multiple Choice

Which type of CSS is defined within a <style> tag in the <head> section of the HTML document?

1

a) Inline CSS

2

b) Internal CSS

3

c) External CSS

4

d) CSS Framework

17

Multiple Choice

What is a disadvantage of Inline CSS?

1

a) It is easy to maintain.

2

b) It allows for quick style application.

3

c) It is not reusable.

4

d) It keeps HTML files cleaner.

18

Multiple Choice

What is a disadvantage of Internal CSS?

1

a) Styles are centralized within the HTML file.

2

b) It is not reusable across multiple HTML files.

3

c) It makes the HTML file cleaner.

4

d) It is easier to maintain compared to Inline CSS.

19

media

20

media

21

media

22

media

23

media

24

media

25

media

26

media

27

Multiple Choice

Html contains _____ types of block elements

1

2

2

3

3

4

4

5

28

media

29

media

30

media

31

media

32

media

33

media

34

Multiple Choice

block level element flows from

1

up to down

2

left to right

3

down to up

4

right to left

35

media

36

media

37

media

38

Multiple Select

select the correct answers

1

block level/block elements can have height and width.

2

the width of block elements are the full width of viewport by default

3

block level elements flows from right to left

4

block level elements can have inline elements as child

39

Multiple Select

Block level elements can have which of the following properties?

1

a) Height and width

2

b) Background color

3

c) Padding and margin

4

d) None of the above

40

Multiple Choice

Which of the following is true about block elements?

1

 a) They always start on a new line

2

b) They do not support width and height properties

3

c) They are used only for text formatting

4

d) They cannot contain other block elements

41

Multiple Choice

Which of the following HTML elements are block elements?

 

1

a) <div>

2

b) <span>

3

c) <img>

4

d) <a>

42

media

43

media

44

media

45

media

46

media

47

Multiple Select

Select the correct answers

Inline elements-

1

cannot have height and width

2

can have block level element as child

3

do not have margin and padding

4

flows from top to bottom

48

Multiple Choice

Inline elements are typically used for:

 

1

a) Structuring page layout

2

b) Text formatting

3

c) Creating navigation menus

4

d) Embedding videos

49

Multiple Choice

An example of an inline element is:

 

1

a) <div>

2

b) <h1>

3

c) <span>

4

d) <p>

50

media

51

media

52

media

53

media

54

Multiple Select

select the right answers

inline-block elements

1

can have height and width

2

flows from left to right

3

flows from top to bottom

4

can have block element as child

55

Multiple Choice

An example of an inline-block element is:

1

 a) <ul>

2

b) <h2>

3

c) <span>

4

d) <img>

56

media

57

media

58

media

59

media

60

media

61

media

62

media

63

media

64

media

65

media

66

media

67

media

68

media

69

media

70

media

71

media

72

media

73

media

74

media

75

media

76

Introduction to HTML Forms

Benefit of HTML Forms:

  • HTML forms are used to collect user input.

  • They can contain various types of input elements such as text fields, checkboxes, radio buttons, and submit buttons.

  • Forms are essential for user interaction on websites.

77

Basic Structure of an HTML Form

<form action="/submit_form" method="post">

<label for="name">Name:</label>

<input type="text" id="name" name="name"><br><br>

<input type="submit" value="Submit">

</form>

action: URL where the form data will be sent.

method: HTTP method (GET or POST).

78

Common Input Types

Types of input elements:

  • Text input: <input type="text">

  • Email input: <input type="email">

  • Number input: <input type="number">

  • Radio buttons: <input type="radio">

  • Checkboxes: <input type="checkbox">

    <label for="email">Email:</label>

    <input type="email" id="email" name="email"><br>

79

Form Validation

HTML5 introduces built-in validation attributes:

  • required

  • pattern

  • minlength maxlength

<input type="text" id="username" name="username" required minlength="5" maxlength="15"><br><br>

required: Ensures the field must be filled out.

pattern: Specifies a regex pattern for validation.

minlength and maxlength: Limits the number of characters.

80

Multiple Choice

What is the primary purpose of an HTML form?

1

A) To display images

2

B) To create hyperlinks

3

C) To collect user input

4

D) To format text

81

Multiple Choice

Which attribute in the <form> element specifies the URL where the form data will be sent?

1

A) method

2

B) action

3

C) enctype

4

D) target

82

Multiple Choice

What does the required attribute do in an HTML input element?

1

A) Limits the number of characters that can be entered

2

B) Specifies a URL to validate the input

3

C) Ensures the input field must be filled out before submitting the form

4

D) Sets a default value for the input field

83

media
media

Show answer

Auto Play

Slide 1 / 83

SLIDE