HTML-and-CSS-QuickStart-Guide
HTML-and-CSS-QuickStart-Guide
🌐
QuickStart Guide
and CSS!
Learn more about HTML
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
1
3. Function of the pattern Attribute in an HTML5 Input Field 14
4. Role of the placeholder Attribute in an Input Field 14
5. Purpose of the maxlength Attribute in an <input> Element 15
6. Function of the form Attribute of the <button> Element in HTML5 15
7. Function of the placeholder Attribute in HTML5 Input Elements 15
8. Purpose of the formaction Attribute in an <input type="submit"> Element 15
9. Function of the nowrap Attribute in a <td> Element in HTML5 16
HTML5 Media and Graphics 16
1. Embedding Video Files with the <video> Element 16
2. Drawing Graphics with the <canvas> Element 17
3. Embedding Audio Files with the <audio> Element 17
4. Using Scalable Vector Graphics (SVG) 18
5. Embedding External Media with the <embed> and <object> Elements 18
Advanced HTML5 Features 19
1. async Attribute in a <script> Tag 19
2. Purpose of the <output> Element 19
3. Purpose of the <article> Element 20
4. Required Attribute for Input Fields 20
5. ContentEditable Attribute 20
6. Purpose of the <figure> Element 20
7. defer Attribute in a <script> Tag 21
8. kind Attribute of the <track> Element 21
9. cols Attribute of the <textarea> Element 21
10. Role of the alt Attribute for Images 22
11. download Attribute in the <a> Tag 22
12. Purpose of the <figcaption> Element 22
13. Default Value of the type Attribute for a <button> Element 22
14. Element for Displaying the Result of a Calculation 23
15. Specifying Character Encoding with charset Attribute 23
16. Caption for a Figure Element 23
17. Indicating a New Article Element 23
18. Specifying Metadata with <meta> Element 23
19. Control for Generating a Public-Private Key Pair 24
20. href Attribute in the <a> Tag 24
21. Marking Up a Time-Stamp 24
22. Purpose of the autofocus Attribute 24
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
2
23. Specifying an Ordered List 25
24. Defining Emphasized Text 25
25. disabled Attribute in HTML5 25
26. Representing a Scalar Value within a Range 25
27. multiple Attribute in an <input> Element 25
HTML Quiz Questions 26
CSS Tip and Basics: 62
1. What does CSS stand for? 62
2. HTML Tag for Defining an Internal Style Sheet: 62
3. Selecting an Element with ID "demo" in CSS: 63
4. Selecting Elements with Class Name "example": 63
5. Capitalizing Each Word in a Text: 63
6. Changing the Background Color: 63
7. Changing the Font of an Element: 64
8. Making a List with Square Items: 64
9. Selecting All <p> Elements Inside a <div>: 64
10. Understanding the Given CSS Code: 64
Text Styling and Formatting in CSS: Detailed Guide with Examples 65
1. CSS Property for Text Size: 65
2. Displaying Hyperlinks Without Underline: 65
3. Changing Left Margin of an Element: 65
4. Making Text Bold: 65
5. Setting Spacing Between Words: 66
6. Changing the Font Name: 66
7. Making a Border Visible on All Sides of a Box: 66
8. Changing Font Color of an Element: 66
9. Default Value of the Position Property: 66
10. Creating a Circle Shape in CSS: 67
11. Applying CSS Style for a Component with Two Specific Classes: 67
Selectors and Specificity in CSS: A Comprehensive Guide with Examples 67
1. Setting Background Image of an Element: 67
2. Displaying List Items Inline: 68
3. Controlling Layout and Formatting of <fieldset> Element: 68
4. Creating Rounded Corners Using CSS: 68
5. Selecting All <p> Elements with a <div> Parent: 69
6. Adding Shadow to Elements: 69
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
3
7. Meaning of h1 + p in CSS: 69
8. Specifying Space Between Cells in a Table: 69
9. Setting Opacity of an Element: 70
10. Purpose of the z-index Property: 70
Layout and Positioning in CSS: Detailed Insights with Examples 70
1. Function of the CSS Display Property: 70
2. Selecting All Child <p> Elements of a <div>: 71
3. Invalid CSS Unit: 71
4. Purpose of the Overflow Property in CSS: 71
5. Difference Between visibility and display: 71
6. Changing Cursor Type on Hover: 72
7. Using :nth-child() Pseudo-Class in CSS: 72
8. Default Position Value in CSS: 72
9. Adding a Comment in a CSS File: 72
Box Model, Borders, and Layout in CSS: In-Depth Explorations 73
1. Creating Space Around Elements (Outside Borders): 73
2. The Flex Property in CSS Flexbox Layout: 73
3. Purpose of the Clear Property in CSS: 73
4. Controlling Text Wrapping in CSS: 73
5. Creating a Numbered List: 74
6. Moving Content Away from Borders: 74
7. Default Display Value for Most Elements: 74
8. Function of the :after Pseudo-Element: 74
9. Selecting Every <p> Element Whose Parent is Not a <div>: 75
10. Changing Style of the Bottom Border: 75
11. Effect of position: relative; in CSS: 75
Transformations and Animations in CSS: Essential Techniques and Examples 75
1. Changing Color of an Element on Mouse Hover: 76
2. Creating a Drop Shadow Effect: 76
3. Controlling Space Between Letters: 76
4. Changing Order of Flex Items: 76
5. Center Aligning Text Horizontally: 77
6. Adding a Border to an Element: 77
7. Making Font Italic: 77
8. Creating Rounded Corners with Specific Radius: 77
9. Making Text Bold: 78
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
4
Spacing and Alignment in CSS: Detailed Guide with Examples 78
1. Specifying Space Between Lines of Text: 78
2. Applying Styles to the First Letter of a Text Element: 78
3. Transforming Text to Uppercase: 78
4. Purpose of the rgba() Color Format: 79
5. Controlling Width of an Element's Border: 79
6. Changing Background Color on Mouse Hover: 79
7. Specifying List Item Markers: 79
8. Purpose of the CSS Overflow-x Property: 80
9. Selecting All Even Rows of a Table: 80
10. Purpose of text-decoration: underline;: 80
Pseudo-Classes and Elements in CSS: A Comprehensive Exploration 80
1. Changing Color of Visited Links: 81
2. Applying Styles to Every Second Element: 81
3. Controlling Order of Columns in CSS Grid: 81
4. The display: inline-block; Property: 81
5. Selecting the First Child of a Specific Element Type: 82
6. Purpose of text-align: center;: 82
7. Control by background-repeat Property: 82
8. Controlling Space Between Columns in CSS Grid: 82
9. Controlling Order of Items in Flexbox: 83
10. Creating a CSS Class for Elements with a Specific Attribute: 83
Other Styling and Effects in CSS: Detailed Explanations and Examples 83
1. flex-direction in Flexbox Layout: 83
2. Purpose of white-space: nowrap;: 84
3. Applying Styles on Hover of Parent Element: 84
4. Spacing Between Characters: 84
5. Vertical Text Alignment: 84
6. Selecting the Last Child of a Specific Element Type: 85
7. cursor: pointer; Property: 85
8. Purpose of text-overflow: ellipsis;: 85
9. Specifying Style of an Element's Border: 85
10. font-family Property: 85
11. Controlling Transparency: 86
12. Selecting Elements with a Specific Class: 86
13. box-sizing: border-box; Property: 86
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
5
14. Selecting Links Within a Specific Section: 86
15. Creating a Shadow Behind an Element's Border: 87
16. Selecting the Last Element of a Specific Type: 87
17. Creating a Rotating Animation: 87
18. text-decoration: none; Property: 87
19. Selecting the First Element of a Specific Type: 88
20. Controlling Spacing Between Lines of Text: 88
CSS Quiz Questions 88
Example:
<head>
<title>Page Title</title>
</head>
<body>
<h1>This is a Heading</h1>
<p>This is a paragraph.</p>
</body>
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
6
● Semantic Elements: <header>, <footer>, <article>, etc.
● Non-Semantic Elements: <div>, <span>, etc.
Tip: Use semantic elements for better readability and accessibility. They
help screen readers and search engines to better understand the content of
your website.
Example:
<head>
<title>Document Title</title>
</head>
<body>
<p>This document is in English.</p>
</body>
Tip: Always set the lang attribute in your HTML document for better
accessibility and SEO.
Example:
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
7
This viewport tag sets the width of the page to follow the screen-width of
the device (which varies depending on the device), and sets the initial
zoom level when the page is first loaded by the browser.
Tip: Always use the viewport meta tag in an HTML5 document to ensure
your site is mobile-friendly.
Example:
<footer>
<p>Copyright © 2021 Company Name</p>
</footer>
Example:
<canvas id="myCanvas"></canvas>
<script>
var canvas = document.getElementById('myCanvas');
var ctx = canvas.getContext('2d');
ctx.fillStyle = 'green';
ctx.fillRect(10, 10, 100, 100);
</script>
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
8
Example:
<nav>
<a href="/">Home</a> |
<a href="/about">About</a> |
<a href="/contact">Contact</a>
</nav>
Example:
<audio controls>
<source src="audiofile.mp3" type="audio/mpeg">
Your browser does not support the audio tag.
</audio>
Example:
<p>First topic...</p>
<hr>
<p>Second topic...</p>
Example:
<header>
<h1>Website Title</h1>
<p>Welcome to my website</p>
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
9
</header>
Example:
<article>
<h2>Article Title</h2>
<p>Article content...</p>
</article>
Example:
<section id="chapter1">
<h2>Chapter 1: Introduction</h2>
<p>Chapter content...</p>
</section>
Example:
<menu type="toolbar">
<li><button type="button">Home</button></li>
<li><button type="button">Products</button></li>
</menu>
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
10
Example:
Example:
<header>
<h1>Welcome to My Blog</h1>
<p>Your source for news and articles.</p>
</header>
Example:
<aside>
<h2>Related Articles</h2>
<ul>
<li>Article 1</li>
<li>Article 2</li>
</ul>
</aside>
Example:
<ul>
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
11
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3</li>
</ul>
Example:
<section>
<h2>About Us</h2>
<p>Information about the company...</p>
</section>
Example:
<header>
<h1>My Website</h1>
<nav>
<a href="/">Home</a> |
<a href="/about">About</a>
</nav>
</header>
Example:
<article>
<h2>Blog Post Title</h2>
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
12
<p>Blog post content...</p>
</article>
Example:
<video controls>
<source src="movie.mp4" type="video/mp4">
<source src="movie.ogg" type="video/ogg">
Your browser does not support the video tag.
</video>
Example:
<blockquote cite="http://source.com">
<p>This is a quoted text from a source.</p>
</blockquote>
These HTML5 elements and tags are essential for structuring and enriching
web content, ensuring it is semantically meaningful and accessible. They
play a crucial role in the overall design and functionality of web pages.
Example:
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
13
<!-- Valid input type -->
<input type="text" name="name">
<!-- Invalid input type -->
<input type="slider" name="slider">
Example:
Example:
Example:
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
14
<input type="text" name="name" placeholder="Enter your name">
Example:
Example:
<form id="loginForm">
<!-- form content -->
</form>
<button form="loginForm" type="submit">Submit</button>
Example:
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
15
Example:
<form action="/default-action">
<input type="submit" value="Submit to Default">
<input type="submit" formaction="/different-action" value="Submit to
Different">
</form>
Example:
Example:
Tips:
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
16
● Add a text message inside the <video> tag for browsers that do not
support it.
Example:
Tips:
Example:
<audio controls>
<source src="sound.mp3" type="audio/mpeg">
<source src="sound.ogg" type="audio/ogg">
Your browser does not support the audio element.
</audio>
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
17
Tips:
Example:
Tips:
● SVG is great for high-quality graphics that need to scale for different
device sizes.
● You can style SVG elements with CSS and make them interactive
with JavaScript.
Example of <embed>:
Example of <object>:
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
18
<embed src="file.swf" width="400" height="50">
</object>
Tips:
Example:
Tips:
Example:
<form oninput="result.value=parseInt(a.value)+parseInt(b.value)">
<input type="range" id="a" value="50">+
<input type="number" id="b" value="50">
<output name="result" for="a b">100</output>
</form>
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
19
3. Purpose of the <article> Element
The <article> element represents a self-contained composition in a
document, page, or site, which is intended to be independently distributable
or reusable.
Example:
<article>
<h2>Article Heading</h2>
<p>Article content...</p>
</article>
Tips:
● Use it for blog posts, news articles, user comments, or other items of
independent content.
Example:
5. ContentEditable Attribute
The contenteditable attribute specifies whether the content of an element is
editable or not.
Example:
Example:
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
20
<figure>
<img src="image.jpg" alt="Image description">
<figcaption>Caption for the image.</figcaption>
</figure>
Example:
Tips:
● Use defer for scripts that need the DOM to be fully parsed.
Example:
<video controls>
<source src="movie.mp4" type="video/mp4">
<track src="subtitles_en.vtt" kind="subtitles" srclang="en" label="English">
</video>
Example:
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
21
The alt attribute provides alternative text for an image if it cannot be
displayed.
Example:
Tips:
Example:
Example:
<figure>
<img src="image.jpg" alt="...">
<figcaption>Caption goes here.</figcaption>
</figure>
Example:
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
22
The <output> element is used for displaying the result of a calculation.
Example:
<output name="result"></output>
Example:
<meta charset="UTF-8">
Example:
<figure>
<img src="image.jpg" alt="...">
<figcaption>This is a caption.</figcaption>
</figure>
Example:
<article>
<h2>New Article</h2>
<p>Content of the new article...</p>
</article>
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
23
Example:
Example:
Note: It's recommended to use more modern and secure methods for key
generation.
Example:
Example:
Example:
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
24
23. Specifying an Ordered List
The <ol> tag is used to specify an ordered list in HTML5.
Example:
<ol>
<li>First item</li>
<li>Second item</li>
</ol>
Example:
Example:
Example:
Example:
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
25
<input type="file" multiple>
1. <div>
2. <table>
3. <article>
4. <font>
Answer: 3. <article>
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
26
4. To display 3D objects
1. <bottom>
2. <footer>
3. <section>
4. <div>
Answer: 2. <footer>
Question 5: What is the correct HTML5 element for playing video files?
1. <media>
2. <video>
3. <film>
4. <mp4>
Answer: 2. <video>
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
27
Question 6: Which of the following is NOT a valid type for <input> in HTML5?
1. email
2. date
3. slider
4. color
Answer: 3. slider
Explanation: In HTML5, slider is not a valid type attribute value for <input>.
The correct type for a slider is range.
Question 7: Which HTML5 element is used for drawing graphics, typically via
JavaScript?
1. <graphics>
2. <canvas>
3. <svg>
4. <draw>
Answer: 2. <canvas>
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
28
Explanation: The async attribute in a <script> tag allows the script to be
executed asynchronously as soon as it is available, without waiting for the
entire page to be loaded.
1. <nav>
2. <navigation>
3. <links>
4. <navigate>
Answer: 1. <nav>
1. A calculation or result
2. A unit of length
3. Self-contained content, like illustrations, diagrams, photos, code
listings, etc.
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
29
4. A key figure in a text
Question 12: How do you define a header for a section or page in HTML5?
1. <header>
2. <head>
3. <top>
4. <sectionhead>
Answer: 1. <header>
1. <sound>
2. <mp3>
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
30
3. <audio>
4. <music>
Answer: 3. <audio>
Question 16: Which attribute is used to specify that an input field must be filled
out before submitting the form?
1. required
2. mandatory
3. validate
4. essential
Answer: 1. required
1. To define a comment
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
31
2. To contain a magazine or newspaper article
3. To wrap an article about a particular subject
4. Both 2 and 3
1. <article>
2. <footer>
3. <div>
4. <section>
Answer: 3. <div>
Question 19: Which HTML5 element is used for marking up a thematic break in a
page?
1. <break>
2. <line>
3. <hr>
4. <divider>
Answer: 3. <hr>
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
32
Question 20: Which attribute is used with the meta tag to define the character set
of an HTML document?
1. charset
2. encoding
3. setchar
4. character
Answer: 1. charset
Explanation: The charset attribute in the <meta> tag specifies the character
encoding for the HTML document.
Question 21: What does the placeholder attribute provide in an input field?
1. <section>
2. <article>
3. <aside>
4. <header>
Answer: 2. <article>
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
33
Question 23: What is the correct HTML element for inserting a line break?
1. <br>
2. <break>
3. <lb>
4. <line>
Answer: 1. <br>
Explanation: The <br> tag is used in HTML to insert a line break in text.
Question 24: Which HTML5 element is used for specifying a group of introductory
or navigational aids?
1. <group>
2. <section>
3. <header>
4. <nav>
Answer: 4. <nav>
Question 25: What does the srcset attribute in the <img> element do?
Explanation: The srcset attribute in the <img> tag allows specifying different
images to be displayed based on the screen size or resolution, enabling
responsive image loading.
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
34
Question 26: Which attribute in the <a> tag specifies the URL of the page the link
goes to?
1. href
2. src
3. link
4. url
Answer: 1. href
Explanation: The href attribute in the <a> (anchor) tag specifies the URL of
the page the link goes to.
Explanation: The viewport meta tag is used in HTML5 to control the layout
on mobile browsers. By default, it adjusts the width of the page to the
screen width of the device.
1. <progress>
2. <meter>
3. <task>
4. <loading>
Answer: 1. <progress>
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
35
Explanation: The <progress> element represents the progress of a task in
HTML5.
1. <ul>
2. <ol>
3. <list>
4. <dl>
Answer: 2. <ol>
1. <em>
2. <i>
3. <bold>
4. <strong>
Answer: 1. <em>
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
36
Explanation: The <em> tag is used to define emphasized text in HTML5,
which typically displays as italicized text.
Question 32: What is the default value of the type attribute for a <button>
element in HTML5?
1. button
2. submit
3. reset
4. menu
Answer: 2. submit
Explanation: The default value of the type attribute for a <button> element
is submit.
Question 33: Which HTML5 element is best suited for marking up a time-stamp?
1. <datetime>
2. <timestamp>
3. <time>
4. <date>
Answer: 3. <time>
Answer: 1. To provide a hint to the user about what to enter in the field
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
37
Explanation: The placeholder attribute provides a hint to the user about
what information to enter in the input field.
1. <group>
2. <section>
3. <block>
4. <divide>
Answer: 2. <section>
Question 36: What does the required attribute in an input field ensure in HTML5?
Question 37: Which HTML5 element defines a caption for a figure element?
1. <figcaption>
2. <caption>
3. <title>
4. <headline>
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
38
Answer: 1. <figcaption>
1. <new article>
2. <article new>
3. <article>
4. <newarticle>
Answer: 3. <article>
Question 39: Which HTML5 element is used for specifying metadata about an
HTML document?
1. <meta>
2. <data>
3. <info>
4. <metadata>
Answer: 1. <meta>
Question 40: What is the purpose of the lang attribute in an HTML5 document?
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
39
4. Determines the language for text-to-speech conversion
Explanation: The lang attribute is used to define the language used in the
element, which can be important for screen readers and other assistive
technologies.
1. <keygen>
2. <generator>
3. <publickey>
4. <keypair>
Answer: 1. <keygen>
Question 42: In HTML5, which element is used for displaying the result of a
calculation?
1. <calculate>
2. <result>
3. <output>
4. <return>
Answer: 3. <output>
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
40
Question 43: Which HTML5 element is used to specify a header for a document or
section?
1. <header>
2. <top>
3. <heading>
4. <head>
Answer: 1. <header>
Question 44: Which attribute in HTML5 specifies the character encoding for the
HTML document?
1. charset
2. encoding
3. character
4. setchar
Answer: 1. charset
Explanation: The charset attribute in the <meta> tag specifies the character
encoding for the HTML document.
Question 45: What does the pattern attribute in an HTML5 input field do?
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
41
Answer: 1. Specifies a regular expression the input field's value is checked
against
Question 46: Which HTML5 element is used to define the navigation links?
1. <navigate>
2. <nav>
3. <links>
4. <navigation>
Answer: 2. <nav>
1. <group>
2. <header>
3. <section>
4. <intro>
Answer: 2. <header>
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
42
4. To store configuration settings for JavaScript libraries
Question 49: Which HTML5 element is specifically used for marking up a block of
code?
1. <code>
2. <script>
3. <block>
4. <pre>
Answer: 1. <code>
Question 50: Which element in HTML5 is best used for marking up a scalar
measurement within a known range, like a disk usage?
1. <gauge>
2. <measure>
3. <meter>
4. <range>
Answer: 3. <meter>
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
43
1. Automatically downloads the video or audio
2. Automatically plays the video or audio as soon as it can do so without
stopping
3. Repeats the video or audio automatically after it's finished
4. Plays the video or audio in a loop
Question 52: Which HTML5 attribute specifies whether the content of an element
should be editable or not?
1. editable
2. contenteditable
3. modify
4. changeable
Answer: 2. contenteditable
Question 53: In HTML5, which element is used to define a section of content that
should be independently distributable or reusable?
1. <section>
2. <article>
3. <block>
4. <content>
Answer: 2. <article>
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
44
Explanation: The <article> element represents a self-contained composition
in a document, page, application, or site, which is intended to be
independently distributable or reusable, e.g., in syndication.
Question 54: Which HTML5 element is used for specifying a standard way to
embed a video in a webpage?
1. <movie>
2. <media>
3. <video>
4. <clip>
Answer: 3. <video>
Question 55: What is the main function of the <figcaption> element in HTML5?
Question 56: Which attribute is used to specify the URL of the resource to be used
by the object in HTML5?
1. src
2. data
3. href
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
45
4. type
Answer: 2. data
Question 57: In HTML5, which attribute of the <textarea> element specifies the
visible width of the text control?
1. rows
2. cols
3. length
4. width
Answer: 2. cols
Question 58: What is the role of the alt attribute for images in HTML5?
Question 59: Which HTML5 element is used to specify a header for a section or
page?
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
46
1. <header>
2. <top>
3. <head>
4. <sectionhead>
Answer: 1. <header>
Question 60: In HTML5, which element represents a command that a user can
perform or activate?
1. <command>
2. <button>
3. <action>
4. <do>
Answer: 2. <button>
Question 61: What is the correct HTML5 element for playing audio files?
1. <sound>
2. <audio>
3. <mp3>
4. <music>
Answer: 2. <audio>
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
47
1. <nav>
2. <navigate>
3. <links>
4. <navigation>
Answer: 1. <nav>
Question 63: Which HTML5 element is used to define a part of text in an alternate
voice or mood?
1. <mark>
2. <em>
3. <strong>
4. <sarcasm>
Answer: 2. <em>
1. <em>
2. <i>
3. <bold>
4. <strong>
Answer: 1. <em>
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
48
Question 65: Which HTML5 element is used to represent a piece of a webpage
that is independent of its surroundings?
1. <section>
2. <article>
3. <aside>
4. <block>
Answer: 2. <article>
Question 66: Which attribute in HTML5 is used to specify that an input element
should be disabled?
1. disable
2. inactive
3. off
4. disabled
Answer: 4. disabled
Question 67: What is the purpose of the download attribute in the <a> tag in
HTML5?
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
49
Explanation: The download attribute, when present, indicates that the
author intends the hyperlink to be used for downloading a resource.
1. <section>
2. <article>
3. <aside>
4. <block>
Answer: 2. <article>
Question 69: In HTML5, what does the async attribute in a <script> tag do?
Question 70: What is the purpose of the defer attribute in a <script> tag in
HTML5?
1. To delay the execution of the script until after the page has finished
parsing
2. To run the script in the background
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
50
3. To load the script after all images have loaded
4. To execute the script immediately
Answer: 1. To delay the execution of the script until after the page has
finished parsing
1. <link>
2. <nav>
3. <connect>
4. <relation>
Answer: 2. <nav>
Question 72: In HTML5, which element is used to represent data with more than
one dimension?
1. <data>
2. <datalist>
3. <table>
4. <grid>
Answer: 3. <table>
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
51
Question 73: What does the controls attribute do in a <video> or <audio> element
in HTML5?
Answer: 1. Adds video or audio controls like play, pause, and volume
1. <cmd>
2. <list>
3. <command>
4. <menu>
Answer: 4. <menu>
Question 75: In HTML5, which element is used to define additional details that the
user can view or hide?
1. <details>
2. <summary>
3. <extra>
4. <moreinfo>
Answer: 1. <details>
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
52
Explanation: The <details> element is used to specify additional details that
the user can view or hide on demand.
Question 76: Which HTML5 element is used to define a control for entering a date
(year, month, and day, with no time)?
1. <datetime>
2. <date>
3. <input type="date">
4. <calendar>
Question 77: What is the purpose of the for attribute in the <label> element in
HTML5?
Explanation: The for attribute in the <label> element specifies which form
element a label is bound to.
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
53
Answer: 1. To define a caption for a <figure> element
Question 79: Which HTML5 element is used to define a container for an external
application or interactive content (a plug-in)?
1. <embed>
2. <app>
3. <interactive>
4. <external>
Answer: 1. <embed>
1. <code>
2. <program>
3. <script>
4. <computercode>
Answer: 1. <code>
Question 81: What is the purpose of the autoplay attribute in HTML5 media
elements like <video> and <audio>?
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
54
1. To start playing the media automatically when the page is loaded
2. To continuously play the media in a loop
3. To preload the media when the page is loaded
4. To mute the media by default
1. <break>
2. <change>
3. <hr>
4. <divider>
Answer: 3. <hr>
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
55
Answer: 4. Both 2 and 3
1. <section>
2. <part>
3. <division>
4. <area>
Answer: 1. <section>
1. <header>
2. <intro>
3. <navigation>
4. <top>
Answer: 1. <header>
Question 86: Which HTML5 element is used for content that is tangentially related
to the content around it, like a sidebar?
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
56
1. <sidebar>
2. <related>
3. <aside>
4. <tangent>
Answer: 3. <aside>
Question 87: What is the purpose of the preload attribute in a <video> or <audio>
element in HTML5?
Explanation: The preload attribute specifies if and how the author thinks
that the video/audio should be loaded when the page loads. It allows
buffering enough media to start playing.
Question 88: In HTML5, which attribute for the <meta> tag specifies the
description of the page?
1. content
2. description
3. name="description"
4. meta-description
Answer: 3. name="description"
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
57
Question 89: Which HTML5 element represents a list of items where the order of
the items is not important?
1. <ol>
2. <ul>
3. <list>
4. <items>
Answer: 2. <ul>
Question 90: In HTML5, which attribute of the <track> element specifies the kind
of text track?
1. type
2. kind
3. mode
4. track-type
Answer: 2. kind
Explanation: The kind attribute of the <track> element specifies the kind of
text track (subtitles, captions, descriptions, chapters, or metadata).
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
58
Explanation: The maxlength attribute specifies the maximum length of the
input value in terms of the number of characters allowed.
Question 92: Which HTML5 element is used to represent a scalar value within a
known range, such as the volume control?
1. <range>
2. <measure>
3. <slider>
4. <input type="range">
Question 93: In HTML5, what does the form attribute of the <button> element
specify?
Explanation: The form attribute of the <button> element specifies the form
the button belongs to, linking the button to a specific form even if it is not
contained within it.
Question 94: What is the function of the placeholder attribute in HTML5 input
elements?
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
59
2. To set a default value that is submitted with the form
3. To display a label within the input element
4. To store temporary data until the form is submitted
Question 95: Which HTML5 element defines a group of media content, and is
typically used with the <audio> or <video> elements?
1. <media>
2. <group>
3. <source>
4. <track>
Answer: 3. <source>
Question 96: In HTML5, which element is used to define a container for vector
graphics?
1. <svg>
2. <vector>
3. <graphics>
4. <draw>
Answer: 1. <svg>
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
60
Explanation: The <svg> (Scalable Vector Graphics) element is used to
define a container for vector graphics in HTML5.
1. To specify the action for the form where the input element is located
2. To override the form's action attribute for that specific submit button
3. To define a group of actions for form submission
4. To specify the method of form submission
Answer: 2. To override the form's action attribute for that specific submit
button
Question 98: Which HTML5 element is used to define a block of text that has been
quoted from another source?
1. <blockquote>
2. <quote>
3. <citation>
4. <source>
Answer: 1. <blockquote>
Question 99: In HTML5, what does the nowrap attribute in a <td> element do?
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
61
3. Aligns the text to the top of the cell
4. Stretches the cell to fit the largest item
Question 100: Which HTML5 element is used to define a header for a document
or section?
1. <head>
2. <header>
3. <top>
4. <sectionhead>
Answer: 2. <header>
Purpose: It's used for designing and customizing the appearance of web pages by
styling HTML elements.
<head>
<style>
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
62
body { background-color: lightblue; }
</style>
</head>
Tip: Internal style sheets are useful for single-page styles. For larger projects,
external CSS files are recommended.
#demo {
color: blue;
}
Tip: IDs are unique to each element, making #demo select the specific element
with id="demo".
.example {
font-size: 20px;
}
Tip: Class selectors are used to select and style all elements with the specified
class attribute.
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
63
body {
background-color: lightgray;
}
Tip: You can use color names, RGB, RGBA, HEX, etc., as values for this property.
p{
font-family: Arial, sans-serif;
}
Tip: Always provide a fallback font (like sans-serif or serif) in case the first choice
font isn't available.
div p {
color: red;
}
Tip: This selects all <p> elements that are inside any <div> element.
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
64
Text Styling and Formatting in CSS: Detailed
Guide with Examples
1. CSS Property for Text Size:
Property: font-size
p{
font-size: 16px;
}
Tip: You can use different units like px, em, rem, or % for setting the size.
Tip: You can also use margin shorthand to set margins for all sides.
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
65
5. Setting Spacing Between Words:
Property: word-spacing
p{
word-spacing: 5px;
}
body {
font-family: 'Arial', sans-serif;
}
Tip: Always provide a fallback font type. Use font names in quotes if they contain
spaces.
Tip: color can be specified using names, HEX, RGB, or HSL values.
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
66
In static positioning, elements are positioned according to the normal flow of the
document.
Tip: border-radius: 50% transforms a square into a circle. Ensure height and width
are equal.
Tip: This rule will only apply to elements that have both classOne and classTwo.
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
67
Tip: The URL should point to the image you want to set as the background. It can
be a relative or absolute path.
li {
display: inline;
}
Tip: This makes list items appear in a row, rather than the default stacked
vertically.
fieldset {
border: 2px solid gray;
padding: 10px;
width: 50%;
}
Tip: Customize your <fieldset> elements using these standard CSS properties to fit
the layout of your form.
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
68
5. Selecting All <p> Elements with a <div> Parent:
Selector: Descendant combinator (space)
div p {
color: blue;
}
Tip: This selector targets all <p> elements that are inside a <div> element.
Tip: The box-shadow property takes values for horizontal offset, vertical offset,
blur radius, and color.
7. Meaning of h1 + p in CSS:
Represents: The adjacent sibling combinator.
It selects a <p> element immediately following an <h1>.
h1 + p {
font-weight: bold;
}
Tip: This is useful when you want to style an element that directly follows another
specific element.
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
69
9. Setting Opacity of an Element:
Property: opacity
div {
opacity: 0.5; /* 50% transparency */
}
Tip: opacity ranges from 0 (completely transparent) to 1 (completely opaque).
Tip: Elements with a higher z-index cover those with a lower one. It works only on
elements with a position value other than static.
Tip: Common values include block, inline, inline-block, none, and more recently,
flex and grid.
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
70
2. Selecting All Child <p> Elements of a <div>:
Selector: Child combinator (>)
div > p {
color: blue;
}
Tip: This selector targets only <p> elements that are direct children of a <div>.
div {
overflow: hidden; /* Hides content that overflows the div's box */
}
display: none; removes the element from the document flow, and it takes up no
space.
.hidden {
visibility: hidden;
}
.gone {
display: none;
}
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
71
Tip: Use display: none; for removing an element completely and visibility: hidden;
to hide but maintain space.
button:hover {
cursor: pointer; /* Changes the cursor to a pointer when hovering over a
button */
}
Tip: cursor can be set to various values like default, pointer, crosshair, etc.
Tip: You can use formulas like nth-child(2n+1) for complex selections.
In this default state, elements are positioned according to the normal flow of the
document.
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
72
Box Model, Borders, and Layout in CSS:
In-Depth Explorations
1. Creating Space Around Elements (Outside
Borders):
Property: margin
div {
margin: 10px; /* Creates 10px space around the div */
}
Tip: margin can be set for each side individually (e.g., margin-top, margin-right,
etc.) or using shorthand notation.
div {
clear: both; /* Neither left nor right floating elements will affect this div */
}
Tip: Commonly used in layouts where floating elements are involved, ensuring
consistent spacing and alignment.
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
73
p{
white-space: nowrap; /* Prevents text from wrapping to a new line */
}
<ol>
<li>First item</li>
<li>Second item</li>
</ol>
Tip: <ol> automatically creates a numbered list, with <li> for each item.
div {
padding: 15px; /* Adds space between the content and the border of the
div */
}
Tip: Padding increases the internal space within an element, unlike margins which
create space outside.
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
74
Tip: Commonly used for decorative elements or to append content.
:not(div) > p {
color: red; /* Styles <p> elements that are not direct children of <div> */
}
Tip: This selector is versatile for excluding specific parent-child relationships.
div {
border-bottom: 2px solid blue; /* Sets a blue bottom border for div */
}
Tip: Similar properties exist for border-top, border-left, and border-right.
div {
position: relative;
top: 10px; /* Moves the div 10px down from its original position */
}
Tip: Relative positioning doesn’t remove the element from the normal document
flow, unlike absolute positioning.
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
75
1. Changing Color of an Element on Mouse Hover:
Property: :hover pseudo-class
button:hover {
color: red; /* Changes the text color to red when the mouse hovers over it
*/
}
Tip: The :hover pseudo-class can be applied to almost any element, not just links.
div {
box-shadow: 5px 5px 10px grey; /* Adds a grey shadow to the div */
}
Tip: box-shadow can accept multiple values to create complex shadow effects.
.flex-item {
order: 2; /* Changes the order of this flex item */
}
Tip: Items in a flex container can be reordered without changing the HTML
structure.
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
76
5. Center Aligning Text Horizontally:
Property: text-align
p{
text-align: center; /* Horizontally centers the text inside a paragraph */
}
Tip: text-align: center; is one of the most commonly used properties for text
alignment.
div {
border: 1px solid black; /* Adds a solid black border */
}
Tip: The border property is shorthand for border-width, border-style, and
border-color.
p{
font-style: italic; /* Makes the paragraph text italic */
}
Tip: Other values for font-style include normal and oblique.
Tip: You can specify different radii for each corner (e.g., border-radius: 10px 5px
15px 20px; for top-left, top-right, bottom-right, and bottom-left respectively).
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
77
9. Making Text Bold:
Property: font-weight
strong {
font-weight: bold; /* Makes the text within <strong> bold */
}
Tip: Besides bold, you can also specify numeric values for weight (e.g., 700).
p::first-letter {
font-size: 200%;
color: blue;
}
Tip: This is often used to create a drop cap or stylize the first letter of a paragraph.
p{
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
78
text-transform: uppercase; /* Converts all text in the paragraph to
uppercase */
}
Tip: Other values for text-transform include lowercase, capitalize, and none.
div {
background-color: rgba(255, 0, 0, 0.5); /* Semi-transparent red */
}
Tip: The rgba format is useful for creating overlay effects or semi-transparent
elements.
Tip: This property is widely used for interactive elements like buttons and links to
improve user experience.
ul {
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
79
list-style-type: square; /* Uses squares as the list item marker */
}
Tip: For ordered lists (<ol>), values like decimal or lower-alpha can be used.
tr:nth-child(even) {
background-color: lightgray;
}
Tip: This CSS selector is particularly useful for styling alternate rows in tables for
better readability.
a{
text-decoration: underline; /* Underlines all anchor (link) text */
}
Tip: Commonly used for emphasizing or highlighting text, especially for links.
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
80
1. Changing Color of Visited Links:
Property: :visited pseudo-class
a:visited {
color: purple;
}
Tip: Use :visited to style links differently once they have been clicked. Be mindful
of privacy concerns when styling visited links.
Tip: The order property works in both Flexbox and CSS Grid layouts to control the
sequencing of items.
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
81
Tip: inline-block is useful for aligning elements side by side while still being able to
set width and height.
p:first-child {
font-weight: bold; /* Styles the first paragraph element in its parent */
}
Tip: This selector targets the first occurrence of the specified element within its
parent.
Tip: It's commonly used for centering text or inline elements within a block-level
element.
body {
background-image: url('image.jpg');
background-repeat: no-repeat; /* The image will not be repeated */
}
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
82
}
Tip: column-gap is part of the modern Grid Layout specification, providing a
standardized way to set gaps.
Tip: This selector targets elements based on their attributes, providing a powerful
way to apply styles conditionally.
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
83
2. Purpose of white-space: nowrap;:
Function: Prevents text from wrapping to a new line.
p{
white-space: nowrap; /* Keeps text in a single line */
}
Tip: Useful in situations where text wrapping is not desirable, like in navigational
menus.
div {
display: flex;
align-items: center; /* Vertically centers text in the div */
height: 100px;
}
Tip: Flexbox is a versatile tool for both horizontal and vertical alignment.
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
84
6. Selecting the Last Child of a Specific Element Type:
Pseudo-class: :last-child
p:last-child {
font-weight: bold; /* Styles the last <p> element in its parent */
}
Tip: Targets the last occurrence of the specified element within its parent.
div {
border-style: dashed; /* Sets a dashed border */
}
Tip: Values include solid, dotted, dashed, double, none, etc.
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
85
body {
font-family: "Arial", sans-serif;
}
div {
opacity: 0.5; /* 50% transparent */
}
Tip: The value of opacity ranges from 0 (fully transparent) to 1 (fully opaque).
Tip: Class selectors are the backbone of CSS styling and are widely used due to
their versatility.
div {
box-sizing: border-box;
}
Tip: Makes width and height styling more predictable, especially when adding
padding or borders.
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
86
}
Tip: Replace #sectionId with the actual ID of the section you're targeting.
p:last-of-type {
color: red; /* Styles the last <p> element within its parent */
}
a{
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
87
text-decoration: none;
}
Tip: Essential for custom link styling.
p{
line-height: 1.5; /* 1.5 times the normal line height */
}
Tip: line-height improves text readability and aesthetics, especially in large text
blocks.
Explanation: CSS stands for Cascading Style Sheets. It is used to style and
layout web pages — for example, to alter the font, color, size, and spacing
of your content, split it into multiple columns, or add animations and other
decorative features.
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
88
Question 2: Which HTML tag is used to define an internal style sheet?
1. <style>
2. <css>
3. <script>
4. <link>
Answer: 1. <style>
Explanation:
The <style> tag is used to define style information (CSS) for a single
document. It is placed in the document's head section.
Code Sample:
<head>
<style>
body { background-color: lightblue; }
</style>
</head>
Answer: 2. #demo
Explanation:
In CSS, the hash symbol (#) is used to select elements with a specific id.
Code Sample:
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
89
#demo {
color: blue;
}
Question 4: How do you select elements with the class name "example"?
1. *example
2. #example
3. .example
4. example
Answer: 3. .example
Explanation:
In CSS, the dot (.) is used to select elements with a specific class.
Code Sample:
.example {
font-size: 20px;
}
Question 5: How do you make each word in a text start with a capital letter?
1. text-transform: capitalize;
2. text-transform: uppercase;
3. text-transform: lowercase;
4. text-decoration: capitalize;
Explanation:
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
90
Code Sample:
p{
text-transform: capitalize;
}
Answer: 3. background-color
Explanation:
Code Sample:
body {
background-color: lightblue;
}
Answer: 4. font-family
Explanation:
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
91
The font-family property specifies the font for an element.
Code Sample:
p{
font-family: "Arial", sans-serif;
}
Question 8: How do you make a list that lists its items with squares?
1. list-type: square;
2. list-style-type: square;
3. list-style: square;
4. list-decoration: square;
Explanation:
Code Sample:
ul {
list-style-type: square;
}
Question 9: How do you select all <p> elements inside a <div> element?
1. div p
2. div + p
3. div > p
4. div .p
Answer: 1. div p
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
92
Explanation:
The div p selector selects all <p> elements inside <div> elements.
Code Sample:
div p {
color: red;
}
Question 10: What does the following CSS code do: body { margin: 0; padding: 0;
}?
1. Removes the default margin and padding from all elements
2. Sets the margin and padding of the body element to 0
3. Centers the body element in the viewport
4. Removes the margin and padding from the document
Explanation:
This CSS code sets the margin and padding of the <body> element to 0,
effectively removing the browser's default margin and padding applied to
the body.
Code Sample:
body {
margin: 0;
padding: 0;
}
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
93
4. text-style
Answer: 1. font-size
Explanation: The font-size property in CSS specifies the size of the text in
an element.
Code Sample:
p{
font-size: 16px;
}
Code Sample:
a{
text-decoration: none;
}
Question 13: Which property is used to change the left margin of an element?
1. indent
2. margin-left
3. padding-left
4. border-left
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
94
Answer: 2. margin-left
Code Sample:
div {
margin-left: 20px;
}
Code Sample:
p{
font-weight: bold;
}
Question 15: Which CSS property is used to set the spacing between words?
1. letter-spacing
2. spacing
3. word-spacing
4. text-spacing
Answer: 3. word-spacing
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
95
Explanation: The word-spacing property is used to set the space between
words in a text.
Code Sample:
p{
word-spacing: 2px;
}
Question 16: What is the correct CSS syntax to change the font name?
1. font: Arial;
2. font-name: Arial;
3. font-family: Arial;
4. text-font: Arial;
Code Sample:
p{
font-family: Arial, sans-serif;
}
Question 17: How do you make a border visible on all sides of a box?
1. border-style: solid;
2. border: visible;
3. border-display: all;
4. border-line: solid;
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
96
Explanation: The border-style: solid; property makes a border visible on all
sides of a box.
Code Sample:
div {
border-style: solid;
}
Question 18: Which property is used to change the font color of an element?
1. color
2. font-color
3. text-color
4. color-style
Answer: 1. color
Explanation: The color property is used for setting the color of the text.
Code Sample:
p{
color: red;
}
Answer: 4. static
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
97
Question 20: How can you create a circle shape in CSS?
1. shape: circle;
2. border-radius: 50%;
3. border-circle: 50%;
4. radius: 50%;
Code Sample:
.circle {
width: 100px;
height: 100px;
background-color: red;
border-radius: 50%;
}
Question 21: How do you apply a CSS style for a component with two specific
classes?
1. .class1 + .class2
2. .class1.class2
3. .class1, .class2
4. .class1 > .class2
Answer: 2. .class1.class2
Explanation: To select an element that has both class1 and class2, you
concatenate the class selectors as .class1.class2.
Code Sample:
.class1.class2 {
color: blue;
}
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
98
Question 22: Which property is used to set the background image of an element?
1. background-image
2. background-color
3. background-url
4. image-background
Answer: 1. background-image
Code Sample:
body {
background-image: url('background.jpg');
}
Explanation: The display: inline; property is used to make a list item (or any
element) display inline.
Code Sample:
li {
display: inline;
}
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
99
Question 24: Which CSS property is used for controlling the layout and formatting
of the <fieldset> element?
1. legend
2. fieldset
3. border
4. control
Answer: 3. border
Code Sample:
fieldset {
border: 2px solid green;
}
Question 25: How can you create rounded corners using CSS?
1. corner-style: round;
2. border-round: 10px;
3. border-radius: 10px;
4. edge-round: 10px;
Code Sample:
div {
border-radius: 10px;
}
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
100
Question 26: How do you select all the <p> elements where the parent is a <div>
element?
1. div + p
2. div p
3. div > p
4. p < div
Explanation: The div > p selector selects all <p> elements where the parent
is a <div> element.
Code Sample:
div > p {
color: blue;
}
Answer: 1. box-shadow
Code Sample:
div {
box-shadow: 5px 5px 5px grey;
}
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
101
Question 28: In CSS, what does h1 + p represent?
1. Selects all <p> elements directly after <h1>
2. Selects every <p> element inside <h1>
3. Selects the first <p> element after each <h1>
4. Selects all <p> elements that are siblings of <h1>
Question 29: Which property is used to specify the space between cells in a table?
1. cell-spacing
2. cell-padding
3. border-spacing
4. spacing
Answer: 3. border-spacing
Code Sample:
table {
border-spacing: 5px;
}
Question 30: How can you set the opacity of an element in CSS?
1. opacity: 0.5;
2. visibility: 0.5;
3. alpha: 0.5;
4. transparency: 0.5;
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
102
Explanation: The opacity property is used to set the transparency level of
an element.
Code Sample:
div {
opacity: 0.5;
}
Explanation: The z-index property in CSS is used to specify the stack order
of positioned elements (like absolute, relative, or fixed elements). An
element with a higher z-index is always stacked above one with a lower
index.
Question 32: What does the CSS display: none; property do?
1. Hides an element, but it still takes up space in the layout
2. Hides an element and removes it from the layout
3. Makes the element transparent
4. Displays an element as a block element
Explanation: display: none; not only hides the element, but it also removes
it from the layout. This means the element will not take up any space on the
page.
Question 33: How do you select all child elements of a div that are <p> elements?
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
103
1. div + p
2. div p
3. div > p
4. p < div
Answer: 2. div p
Explanation: The div p selector is used to select all <p> elements that are
descendants of a <div>, regardless of their level of nesting within the div.
Answer: 4. ms
Explanation: ms is not a CSS unit. em, px, and vh are valid CSS units for
various measurements like font size, element size, and viewport height
percentage, respectively.
Explanation: The overflow property specifies how to handle the content that
overflows its container's box, such as displaying scroll bars or cutting off
the overflow.
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
104
Question 36: In CSS, what is the difference between visibility: hidden; and display:
none;?
1. No difference, both hide the element from the page
2. visibility: hidden; hides an element, but it still takes up space in the
layout
3. display: none; changes the visibility to hidden
4. visibility: hidden; removes the element from the document
Explanation: visibility: hidden; hides the element, but it still occupies its
space in the layout. In contrast, display: none; removes the element from
the layout entirely.
Question 37: Which property is used to change the cursor type on hover?
1. cursor-type
2. hover
3. cursor
4. pointer-type
Answer: 3. cursor
Answer: 2. To target elements that are the nth child of their parent
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
105
Explanation: The :nth-child() pseudo-class in CSS is used to select
elements based on their position within a group of siblings.
Answer: 4. static
Explanation: The default value for the position property in CSS is static,
which means the element is positioned according to the normal flow of the
document.
Question 41: Which property is used to create space around elements, outside of
any defined borders?
1. padding
2. margin
3. border
4. spacing
Answer: 2. margin
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
106
Explanation: The margin property in CSS is used to create space around
elements, outside of any defined borders. It's part of the box model, which
also includes padding, border, and the content itself.
Question 42: What does the flex property do in a CSS Flexbox layout?
1. It specifies the direction of the flexible items
2. It controls the alignment of items on the main axis
3. It specifies the length of the item relative to the rest
4. It defines a flexible container for flexible items
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
107
Answer: 3. word-wrap
Question 46: Which CSS property is used to move the content away from the
borders?
1. margin
2. border
3. padding
4. spacing
Answer: 3. padding
Question 47: What is the default display value for most elements?
1. inline
2. block
3. flex
4. grid
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
108
Answer: 2. block
Question 49: How do you select every <p> element whose parent is not a <div>?
1. p:not(div)
2. not(div > p)
3. p:not(div > p)
4. p:not(:parent div)
Explanation: The p:not(div > p) selector is used to select every <p> element
that is not a child of a <div> element.
Question 50: Which property changes the style of the bottom border?
1. border-bottom-style
2. border-bottom
3. border-style-bottom
4. bottom-border
Answer: 1. border-bottom-style
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
109
Explanation: The border-bottom-style property is used to set the style of an
element's bottom border.
Question 51: What does the CSS property position: absolute; do?
1. Makes the element positioned relative to its normal position in the
document
2. Removes the element from the document flow and positions it relative
to its nearest positioned ancestor
3. Aligns the element in the center of the page
4. Makes the element invisible
Answer: 2. Removes the element from the document flow and positions it
relative to its nearest positioned ancestor
Question 52: How do you change the color of an element on mouse hover using
CSS?
1. :hover { color: newColor; }
2. :hover-color { newColor; }
3. hover: { color: newColor; }
4. hover-color: { newColor; }
Code Sample:
a:hover {
color: blue;
}
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
110
Question 53: What is the CSS property used to create a drop shadow effect?
1. text-shadow
2. box-shadow
3. shadow-effect
4. drop-shadow
Answer: 2. box-shadow
Code Sample:
div {
box-shadow: 5px 5px 5px grey;
}
Question 54: Which CSS property is used to control the space between letters in
text?
1. word-spacing
2. line-height
3. letter-spacing
4. text-spacing
Answer: 3. letter-spacing
Code Sample:
p{
letter-spacing: 2px;
}
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
111
Question 55: What is the CSS property for changing the order of flex items in a flex
container?
1. order
2. flex-order
3. item-order
4. flex-item-order
Answer: 1. order
Explanation: The order property in CSS is used to change the order of flex
items in a flex container.
Code Sample:
.flex-item {
order: 2; /* Changes the order to 2 */
}
Question 56: How do you center align text horizontally within an element?
1. text-align: center;
2. horizontal-align: center;
3. center-text: horizontal;
4. align-text: center;
Code Sample:
div {
text-align: center;
}
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
112
Question 57: Which CSS property is used to add a border to an element?
1. border-width
2. border-style
3. border-color
4. border
Answer: 4. border
Code Sample:
div {
border: 2px solid red;
}
Code Sample:
p{
font-style: italic;
}
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
113
Question 59: Which CSS property is used to create rounded corners with a specific
radius?
1. border-radius
2. corner-radius
3. rounded-corners
4. corner-style
Answer: 1. border-radius
Code Sample:
div {
border-radius: 10px;
}
Explanation: The font-weight: bold; CSS property is used to make text bold.
Code Sample:
p{
font-weight: bold;
}
Question 61: Which CSS property is used to specify the amount of space between
lines of text in an element?
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
114
1. line-spacing
2. spacing-line
3. line-height
4. text-spacing
Answer: 3. line-height
Code Sample:
p{
line-height: 1.5;
}
Question 62: How can you apply CSS styles to the first letter of a text element?
1. initial-letter
2. first-letter
3. letter-first
4. start-letter
Answer: 2. first-letter
Explanation: To apply CSS styles to the first letter of a text element, you
can use the ::first-letter pseudo-element.
Code Sample:
p::first-letter {
font-size: larger;
font-weight: bold;
}
Question 63: What does the CSS property text-transform: uppercase; do?
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
115
1. Transforms all text to uppercase letters
2. Transforms the first letter of each word to uppercase
3. Transforms all text to lowercase letters
4. Transforms the last letter of each word to uppercase
Code Sample:
p{
text-transform: uppercase;
}
Question 64: What is the purpose of the rgba() color format in CSS?
1. It specifies the opacity of a color
2. It specifies a color in hexadecimal format
3. It represents a gradient color
4. It defines a color using HSL values
Explanation: The rgba() color format in CSS allows you to specify a color
with an additional alpha channel, representing opacity.
Code Sample:
div {
background-color: rgba(255, 0, 0, 0.5); /* Semi-transparent red */
}
Question 65: Which CSS property is used to control the width of an element's
border?
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
116
1. border-width
2. border-style
3. border-color
4. border-size
Answer: 1. border-width
Code Sample:
div {
border-width: 2px;
}
Question 66: What is the CSS property used to change the background color of an
element on mouse hover?
1. background-color-hover
2. hover-background-color
3. background-hover
4. :hover
Answer: 4. :hover
Code Sample:
button:hover {
background-color: blue;
}
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
117
Question 67: Which CSS property is used to specify the type of list item marker
(e.g., disc, square, or numeric)?
1. list-type
2. marker-style
3. list-marker
4. list-style-type
Answer: 4. list-style-type
Code Sample:
ul {
list-style-type: square;
}
Code Sample:
div {
overflow-x: scroll;
}
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
118
Question 69: How do you select all even rows of a table using CSS?
1. tr:nth-child(even)
2. table:even-row
3. td:nth-child(even)
4. tbody:nth-child(even)
Answer: 1. tr:nth-child(even)
Explanation: You can use the tr:nth-child(even) selector to select all even
rows of a table.
Code Sample:
table tr:nth-child(even) {
background-color: lightgrey;
}
Question 70: What is the purpose of the CSS property text-decoration: underline;?
1. It adds a shadow effect to text
2. It removes the underline from text
3. It adds an underline to text
4. It italicizes the text
Code Sample:
a{
text-decoration: underline;
}
Question 71: What is the CSS property used to change the color of visited links?
1. a:visited-color
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
119
2. visited-link-color
3. link-visited-color
4. color: visited;
Explanation: The CSS property used to change the color of visited links is
a:visited, and it's typically used with the color property to set the color of
visited links.
Code Sample:
a:visited {
color: purple;
}
Question 72: How can you apply CSS styles to every second element of a specific
type?
1. type:nth-child(2n)
2. nth-child(even)
3. type:nth-child(even)
4. :nth-child(2n)
Answer: 4. :nth-child(2n)
Explanation: You can use the :nth-child(2n) selector to apply styles to every
second element of a specific type.
Code Sample:
p:nth-child(2n) {
font-weight: bold;
}
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
120
Question 73: Which CSS property is used to control the order of columns in a CSS
Grid layout?
1. column-order
2. grid-column
3. order
4. grid-template-columns
Answer: 3. order
Explanation: The order property in CSS Grid layout is used to control the
order of grid items within the same container.
Code Sample:
.item {
order: 2; /* Changes the order of this grid item */
}
Code Sample:
.container {
display: flex;
}
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
121
Question 75: How do you select the first-child of a specific element type within its
parent?
1. type:first-child
2. :first-child-type
3. type:nth-child(1)
4. type:first-of-type
Answer: 1. type:first-child
Explanation: To select the first child of a specific element type within its
parent, you can use the type:first-child selector.
Code Sample:
p:first-child {
font-weight: bold;
}
Question 76: What is the purpose of the CSS property text-align: justify;?
1. It centers the text horizontally within an element
2. It adds space between lines of text
3. It justifies the text, creating even left and right margins
4. It aligns text vertically in the center
Answer: 3. It justifies the text, creating even left and right margins
Code Sample:
p{
text-align: justify;
}
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
122
Question 77: What does the background-repeat property in CSS control?
1. It controls the background color of an element
2. It controls the background image's size
3. It controls the repetition of a background image
4. It changes the font style of text
Code Sample:
body {
background-image: url('background.jpg');
background-repeat: repeat-x;
}
Question 78: Which CSS property is used to control the space between columns in
a CSS Grid layout?
1. grid-gap
2. column-gap
3. grid-column-gap
4. grid-column-space
Answer: 1. grid-gap
Explanation: The grid-gap property in CSS Grid layout is used to control the
space between columns and rows.
Code Sample:
.grid-container {
grid-gap: 10px;
}
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
123
Question 79: What is the CSS property used to control the order of items in a
Flexbox layout?
1. flex-order
2. order
3. item-order
4. flex-item-order
Answer: 2. order
Code Sample:
.flex-item {
order: 3; /* Changes the order of this flex item */
}
Question 80: How can you create a CSS class that applies styles to elements with a
specific attribute?
1. .attribute[specific]
2. .class[attribute]
3. [attribute].class
4. [attribute="specific"]
Answer: 4. [attribute="specific"]
Code Sample:
[data-type="button"] {
background-color: blue;
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
124
}
Question 81: What does the CSS property flex-direction control in a Flexbox
layout?
1. It controls the width of flex items
2. It defines the direction of the main axis
3. It sets the background color of flex items
4. It adjusts the font size of flex items
Code Sample:
.container {
flex-direction: column; /* Sets the main axis to be vertical */
}
Question 82: What is the purpose of the CSS property white-space: nowrap;?
1. It sets the text color to white
2. It prevents text from wrapping to the next line
3. It removes all white spaces from text
4. It aligns text vertically in the center
Code Sample:
p{
white-space: nowrap;
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
125
}
Question 83: How do you apply CSS styles to an element when a user hovers over
its parent element?
1. :parent:hover
2. parent:hover > child
3. parent:hover + child
4. parent:hover child
Code Sample:
.container:hover .element {
background-color: yellow;
}
Question 84: Which CSS property is used to control the spacing between
individual characters in text?
1. character-spacing
2. letter-spacing
3. text-spacing
4. word-spacing
Answer: 2. letter-spacing
Code Sample:
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
126
p{
letter-spacing: 2px;
}
Question 85: What is the CSS property used to control the alignment of text within
an element vertically?
1. vertical-align
2. text-align
3. line-height
4. align-items
Answer: 1. vertical-align
Code Sample:
span {
vertical-align: middle;
}
Question 86: How do you select the last-child of a specific element type within its
parent?
1. type:last-child
2. :last-child-type
3. type:last-of-type
4. last-child[type]
Answer: 3. type:last-of-type
Explanation: To select the last child of a specific element type within its
parent, you can use the type:last-of-type selector.
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
127
Code Sample:
p:last-of-type {
font-weight: bold;
}
Question 87: What does the CSS property cursor: pointer; do?
1. It changes the font style of text
2. It specifies the pointer style when hovering over an element
3. It adds a shadow effect to text
4. It sets the text color to a pointer
Code Sample:
button {
cursor: pointer;
}
Question 88: What is the purpose of the CSS property text-overflow: ellipsis;?
1. It controls the text color
2. It adds a shadow effect to text
3. It displays an ellipsis (...) when text overflows its container
4. It changes the font style of text
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
128
Code Sample:
div {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
Question 89: Which CSS property is used to specify the style of an element's
border?
1. border-width
2. border-color
3. border-style
4. border-decoration
Answer: 3. border-style
Code Sample:
div {
border-style: dashed;
}
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
129
Explanation: The font-family property in CSS is used to specify the font
family or typeface to be used for text.
Code Sample:
p{
font-family: "Arial", sans-serif;
}
Question 91: What is the CSS property used to control the transparency of an
element?
1. opacity
2. transparency
3. visibility
4. alpha
Answer: 1. opacity
Code Sample:
div {
opacity: 0.5; /* Makes the element semi-transparent */
}
Question 92: How can you select all elements with a specific class in CSS?
1. .class
2. #class
3. *class
4. class*
Answer: 1. .class
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
130
Explanation: To select all elements with a specific class in CSS, you can
use the .class selector.
Code Sample:
.my-class {
color: red;
}
Question 93: What is the purpose of the CSS property box-sizing: border-box;?
1. It adds a border to the element's box
2. It adjusts the width of an element to include padding and border
3. It sets the box's content to be transparent
4. It centers the element horizontally and vertically
Code Sample:
div {
box-sizing: border-box;
}
Question 94: How do you select all links within a specific section of a web page
using CSS?
1. section a
2. section > a
3. section + a
4. section ~ a
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
131
Answer: 2. section > a
Explanation: To select all links within a specific section of a web page using
CSS, you can use the section > a selector, which selects direct child a
elements of the section.
Code Sample:
section > a {
color: blue;
}
Question 95: What is the CSS property used to create a shadow behind an
element's border?
1. box-shadow
2. border-shadow
3. element-shadow
4. shadow-box
Answer: 1. box-shadow
Code Sample:
div {
box-shadow: 5px 5px 5px grey;
}
Question 96: How do you select the last element of a specific type within its
parent using CSS?
1. type:last
2. :last-type
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
132
3. type:last-of-type
4. last-type[type]
Answer: 3. type:last-of-type
Explanation: To select the last element of a specific type within its parent
using CSS, you can use the type:last-of-type selector.
Code Sample:
p:last-of-type {
font-weight: bold;
}
Answer: 4. animation
Code Sample:
@keyframes rotate {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}
div {
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
133
animation: rotate 2s linear infinite;
}
Question 98: What does the CSS property text-decoration: line-through; do?
1. It removes the text's underline
2. It adds a line through the text
3. It makes the text bold
4. It italicizes the text
Code Sample:
span {
text-decoration: line-through;
}
Question 99: How can you select the first element of a specific type within its
parent using CSS?
1. type:first
2. :first-type
3. type:first-of-type
4. first-type[type]
Answer: 3. type:first-of-type
Explanation: To select the first element of a specific type within its parent
using CSS, you can use the type:first-of-type selector.
Code Sample:
p:first-of-type {
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
134
font-weight: bold;
}
Question 100: What is the CSS property used to control the spacing between lines
of text?
1. line-spacing
2. spacing-line
3. line-height
4. text-spacing
Answer: 3. line-height
Code Sample:
p{
line-height: 1.5;
}
Question 101: Which CSS property is used to control the visibility of an element?
1. display
2. visibility
3. opacity
4. hidden
Answer: 2. visibility
Code Sample:
div {
visibility: hidden; /* Hides the element */
}
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
135
Question 102: How do you select all elements that have a specific attribute in
CSS?
1. [attribute]
2. .attribute
3. #attribute
4. element[attribute]
Answer: 1. [attribute]
Code Sample:
[data-custom] {
color: blue;
}
Question 103: What does the CSS property transform: scale(1.5); do?
1. It rotates the element by 1.5 degrees
2. It scales the element to 1.5 times its size
3. It adds a shadow effect to the element
4. It changes the text color to blue
Code Sample:
div {
transform: scale(1.5);
}
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
136
Question 104: What is the purpose of the CSS property text-transform: capitalize;?
1. It transforms text to uppercase
2. It transforms text to lowercase
3. It capitalizes the first letter of each word
4. It italicizes the text
Code Sample:
p{
text-transform: capitalize;
}
Question 105: How can you select all odd rows of a table using CSS?
1. table:nth-child(odd)
2. tr:nth-child(even)
3. tr:nth-child(odd)
4. table:odd-row
Answer: 3. tr:nth-child(odd)
Explanation: To select all odd rows of a table using CSS, you can use the
tr:nth-child(odd) selector.
Code Sample:
table tr:nth-child(odd) {
background-color: lightgrey;
}
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
137
Question 106: What is the CSS property used to create a rotating animation in 3D?
1. rotate3d
2. transform-3d
3. animation-rotate3d
4. @keyframes rotate3d
Code Sample:
@keyframes rotate3d {
0% {
transform: rotate3d(0, 0, 1, 0deg);
}
100% {
transform: rotate3d(0, 0, 1, 360deg);
}
}
div {
animation: rotate3d 4s linear infinite;
}
Question 107: How can you apply CSS styles to elements with a specific attribute
value?
1. [attribute=value]
2. [value=attribute]
3. [attribute~value]
4. [attribute^value]
Answer: 1. [attribute=value]
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
138
Explanation: To apply CSS styles to elements with a specific attribute
value, you can use the [attribute=value] selector.
Code Sample:
[data-type="button"] {
background-color: blue;
}
Question 108: Which CSS property is used to control the space between lines of
text in a multi-line text element?
1. line-spacing
2. spacing-line
3. line-height
4. text-spacing
Answer: 3. line-height
Code Sample:
p{
line-height: 1.5;
}
Question 109: What is the purpose of the CSS property text-overflow: clip;?
1. It clips the text at the end of the element
2. It clips the text when it overflows its container
3. It removes all white spaces from text
4. It changes the font style of text
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
139
Explanation: There is no text-overflow: clip; property in CSS. The correct
property for clipping text is text-overflow: clip;.
Question 110: How can you select all elements that are not of a specific type using
CSS?
1. :not(type)
2. element:not(type)
3. :not(type)
4. element:not(type)
Answer: 1. :not(type)
Explanation: To select all elements that are not of a specific type using
CSS, you can use the :not(type) selector.
Code Sample:
:not(p) {
font-style: italic;
}
Question 111: What is the CSS property used to control the indentation of the first
line of text within an element?
1. line-indent
2. text-indent
3. first-line-indent
4. indent-first-line
Answer: 2. text-indent
Code Sample:
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
140
p{
text-indent: 20px;
}
Question 112: How do you select the last element of a specific class within its
parent using CSS?
1. class:last-child
2. .class:last-of-type
3. .class:last-child
4. :last-of-type.class
Answer: 3. .class:last-child
Explanation: To select the last element of a specific class within its parent
using CSS, you can use the .class:last-child selector.
Code Sample:
.my-class:last-child {
font-weight: bold;
}
Question 113: What does the CSS property overflow: hidden; do?
1. It hides the element
2. It hides the content that overflows the element's box
3. It adds a shadow effect to the element
4. It changes the font size of text
Explanation: The overflow: hidden; property in CSS hides the content that
overflows the element's box, effectively clipping it.
Code Sample:
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
141
div {
overflow: hidden;
}
Question 114: How can you select the first and last child elements of a specific
type within their parent using CSS?
1. type:first-child, type:last-child
2. type:first-of-type, type:last-of-type
3. type:first, type:last
4. type:first-element, type:last-element
Explanation: To select the first and last child elements of a specific type
within their parent using CSS, you can use the type:first-of-type,
type:last-of-type selector.
Code Sample:
p:first-of-type, p:last-of-type {
font-weight: bold;
}
Question 115: Which CSS property is used to create a shadow effect behind an
element?
1. box-shadow
2. element-shadow
3. shadow-effect
4. shadow-box
Answer: 1. box-shadow
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
142
Code Sample:
div {
box-shadow: 5px 5px 5px grey;
}
Question 116: What is the CSS property used to control the space between
columns in a multi-column layout?
1. column-spacing
2. spacing-column
3. column-gap
4. column-margin
Answer: 3. column-gap
Code Sample:
.container {
column-gap: 20px;
}
Question 117: How can you select all even elements of a specific type within their
parent using CSS?
1. type:nth-child(even)
2. type:nth-of-type(odd)
3. type:nth-child(2n)
4. type:nth-of-type(even)
Answer: 1. type:nth-child(even)
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
143
Explanation: To select all even elements of a specific type within their
parent using CSS, you can use the type:nth-child(even) selector.
Code Sample:
p:nth-child(even) {
background-color: lightgrey;
}
Question 118: What does the CSS property outline: none; do?
1. It adds an outline to the element
2. It removes the border of the element
3. It removes the outline of the element
4. It sets the text color to none
Explanation: The outline: none; property in CSS removes the outline of the
element, often used to remove the default focus outline.
Code Sample:
button {
outline: none;
}
Question 119: Which CSS property is used to control the size of an element's
border?
1. border-width
2. border-size
3. border-dimension
4. border-length
Answer: 1. border-width
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
144
Explanation: The border-width property in CSS is used to control the size of
an element's border.
Code Sample:
div {
border-width: 2px;
}
Question 120: What is the CSS property used to control the background image of
an element?
1. background-image
2. image-background
3. element-image
4. image-element
Answer: 1. background-image
Code Sample:
div {
background-image: url('background.jpg');
}
Question 121: What is the CSS property used to create a gradient background for
an element?
1. background-gradient
2. gradient-background
3. background-image
4. background-linear-gradient
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
145
Answer: 4. background-linear-gradient
Code Sample:
div {
background: linear-gradient(to bottom, #ff0000, #00ff00);
}
Question 122: How can you select all elements that are descendants of a specific
element using CSS?
1. element descendants
2. element > descendants
3. element descendants >
4. element descendants <
Code Sample:
.container > p {
color: blue;
}
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
146
Answer: 3. It defines the shape of the element's border corners
Code Sample:
div {
border-radius: 10px;
}
Question 124: How can you select elements with a specific class that are also
children of a specific element using CSS?
1. .class > element
2. element .class
3. element.class
4. element > .class
Explanation: To select elements with a specific class that are also children
of a specific element using CSS, you can use the element .class selector.
Code Sample:
.container .element {
color: red;
}
Question 125: What is the CSS property used to control the order of flexible items
in a Flexbox layout?
1. flex-direction
2. order
3. flex-order
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
147
4. item-order
Answer: 2. order
Code Sample:
.item {
order: 2; /* Sets the order to 2 */
}
Question 126: How can you select the first child element of a specific type within
its parent using CSS?
1. type:first-child
2. :first-child-type
3. type:first-of-type
4. first-child[type]
Answer: 1. type:first-child
Explanation: To select the first child element of a specific type within its
parent using CSS, you can use the type:first-child selector.
Code Sample:
p:first-child {
font-weight: bold;
}
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
148
4. It adjusts the element's width
Answer: 3. It specifies the order in which elements are stacked along the
z-axis
Code Sample:
div {
z-index: 2;
}
Question 128: How can you select the last element with a specific class within its
parent using CSS?
1. .class:last-child
2. .class:last-of-type
3. .class:last
4. :last-of-type.class
Answer: 2. .class:last-of-type
Explanation: To select the last element with a specific class within its parent
using CSS, you can use the .class:last-of-type selector.
Code Sample:
.my-class:last-of-type {
font-weight: bold;
}
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
149
Question 129: What is the CSS property used to control the alignment of an
element horizontally within its container?
1. horizontal-align
2. align-horizontal
3. text-align
4. align-items
Answer: 3. text-align
Code Sample:
div {
text-align: center; /* Centers the text horizontally */
}
Question 130: What does the CSS property list-style: none; do?
1. It removes list items from the list
2. It sets the list's background color to none
3. It removes the list-style marker (bullet or number) from a list
4. It changes the font style of list items
Code Sample:
ul {
list-style: none;
}
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
150
Question 131: What is the purpose of the CSS property flex-wrap in a
Flexbox layout?
1. It wraps the text content of elements
2. It wraps the elements to the next row when they overflow their
container
3. It adjusts the spacing between Flexbox items
4. It changes the font size of text
Answer: 2. It wraps the elements to the next row when they overflow their
container
Code Sample:
.container {
flex-wrap: wrap;
}
Question 132: How do you select the first element with a specific class within its
parent using CSS?
1. .class:first
2. .class:first-child
3. .class:first-of-type
4. :first-child.class
Answer: 2. .class:first-child
Explanation: To select the first element with a specific class within its parent
using CSS, you can use the .class:first-child selector.
Code Sample:
.my-class:first-child {
font-weight: bold;
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
151
}
Question 133: What is the CSS property used to control the visibility of an element
without affecting its layout?
1. display
2. visibility
3. opacity
4. hidden
Answer: 2. visibility
Code Sample:
div {
visibility: hidden; /* Hides the element without affecting layout */
}
Question 134: How can you select all elements that have a specific attribute with
a value starting with a certain string in CSS?
1. [attribute^="value"]
2. [value^="attribute"]
3. [attribute~="value"]
4. [attribute="value"]
Answer: 1. [attribute^="value"]
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
152
Code Sample:
[data-prefix^="abc"] {
color: red;
}
Question 135: What does the CSS property transform: skew(30deg); do?
1. It rotates the element by 30 degrees
2. It scales the element horizontally by 30 degrees
3. It skews the element horizontally by 30 degrees
4. It changes the text color to blue
Code Sample:
div {
transform: skew(30deg);
}
Question 136: How do you select all even elements within a specific container
using CSS?
1. :even
2. even
3. container:even
4. container :even
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
153
methods, as CSS alone doesn't provide a direct way to select even
elements.
Question 137: What is the CSS property used to control the alignment of an
element vertically within its container?
1. vertical-align
2. align-vertical
3. align-items
4. text-align
Answer: 1. vertical-align
Code Sample:
div {
vertical-align: middle; /* Vertically aligns the element */
}
Question 138: How can you select all elements that are not of a specific class
using CSS?
1. :not(.class)
2. element:not(.class)
3. :not.class
4. element:not.class
Answer: 1. :not(.class)
Explanation: To select all elements that are not of a specific class using
CSS, you can use the :not(.class) selector.
Code Sample:
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
154
:not(.exclude) {
color: red;
}
Question 139: Which CSS property is used to control the size of an element's box
model, including padding and border?
1. box-size
2. box-model-size
3. box-sizing
4. box-dimension
Answer: 3. box-sizing
Code Sample:
div {
box-sizing: border-box;
}
Question 140: What is the CSS property used to control the space between words
in text?
1. word-spacing
2. text-spacing
3. letter-spacing
4. line-spacing
Answer: 1. word-spacing
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
155
Code Sample:
p{
word-spacing: 5px; /* Increases word spacing */
}
Code Sample:
a{
text-decoration: underline;
}
Question 142: How can you select the last element with a specific type within its
parent using CSS?
1. type:last-child
2. :last-of-type(type)
3. :last-type(type)
4. :type(last-child)
Answer: 1. type:last-child
Explanation: To select the last element with a specific type within its parent
using CSS, you can use the type:last-child selector.
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
156
Code Sample:
p:last-child {
font-weight: bold;
}
Question 143: What does the CSS property background-color: transparent; do?
1. It sets the background color to white
2. It makes the background color fully transparent
3. It adds a shadow effect to the background
4. It changes the font style of text
Code Sample:
div {
background-color: transparent; /* Makes the background fully transparent
*/
}
Question 144: How can you select the first element of a specific type that comes
after another element using CSS?
1. element + type:first
2. element + type
3. type + element:first
4. type + element
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
157
Explanation: To select the first element of a specific type that comes after
another element using CSS, you can use the element + type selector.
Code Sample:
p + div {
font-weight: bold;
}
Question 145: What is the CSS property used to control the space between cells in
a table?
1. table-cell-spacing
2. table-spacing
3. cell-spacing
4. border-spacing
Answer: 4. border-spacing
Code Sample:
table {
border-spacing: 10px;
}
Question 146: How can you select all odd elements within a specific container
using CSS?
1. :odd
2. odd
3. container:odd
4. container :odd
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
158
Answer: None of the options.
Question 147: What is the purpose of the CSS property cursor: pointer;?
1. It changes the font size of text
2. It changes the text color to blue
3. It specifies the cursor type when hovering over an element
4. It adds a shadow effect to the element
Explanation: The cursor: pointer; property in CSS specifies the cursor type
to be used when hovering over an element, typically indicating interactivity.
Code Sample:
button {
cursor: pointer; /* Changes cursor to a pointer hand */
}
Question 148: How can you select the first and last elements within a specific
container using CSS?
1. :first, :last
2. first, last
3. container:first, container:last
4. container :first, container :last
Explanation: To select the first and last elements within a specific container
using CSS, you can use the :first and :last selectors.
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
159
Code Sample:
Code Sample:
p{
line-height: 1.5; /* Adjusts line spacing */
}
Question 150: Which CSS property is used to control the order of items in a Grid
layout?
1. grid-order
2. order
3. grid-item-order
4. item-order
Answer: 2. order
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
160
Explanation: The order property in CSS is used to control the order of items
in a Grid layout.
Code Sample:
.item {
order: 2; /* Sets the order of the Grid item */
}
Learn more about JavaScript with Examples and Source Code Laurence Svekis
Courses https://basescripts.com/
161