HTML and CSS Concepts Quiz
46 Questions
0 Views

Choose a study mode

Play Quiz
Study Flashcards
Spaced Repetition
Chat to lesson

Podcast

Play an AI-generated podcast conversation about this lesson

Questions and Answers

What is the purpose of the ‘class' attribute in HTML?

  • To define the type of an element.
  • To group elements for styling purposes. (correct)
  • To specify the order of elements on the page.
  • To uniquely identify an element.
  • Which of the following correctly defines the structure of an HTML document?

  • <header>, <body>, <footer> (correct)
  • <title>, <body>, <footer>
  • <head>, <body>, <html>
  • <html>, <script>, <footer>
  • How does the ‘rgba(R, G, B, A)’ function work in CSS?

  • It defines text alignment.
  • It determines the size of text.
  • It sets the background color of an element.
  • It specifies the transparency level of a color. (correct)
  • What does the CSS declaration 'margin: 40px 100px 120px 80px;' specify?

    <p>Margins in the order of Top, Right, Bottom, Left.</p> Signup and view all the answers

    Which statement about the class names in HTML is true?

    <p>Class names are case sensitive.</p> Signup and view all the answers

    Which property is used to prevent an element from being visible in CSS?

    <p>display: none;</p> Signup and view all the answers

    What does a marquee in HTML do?

    <p>It allows for animated scrolling text or images.</p> Signup and view all the answers

    Which option correctly represents the CSS display properties?

    <p>block, inline, flex, grid, none</p> Signup and view all the answers

    What is the correct syntax for a CSS media query?

    <p>@media screen and (max-width: 800px) {}</p> Signup and view all the answers

    Which statement accurately describes the difference between == and === in JavaScript?

    <p>== compares value only, === compares value and type.</p> Signup and view all the answers

    What is the purpose of the 'next()' function in Express middleware?

    <p>It passes control to the next middleware function.</p> Signup and view all the answers

    What is the primary role of components in Angular?

    <p>To encapsulate UI logic and rendering.</p> Signup and view all the answers

    What does Scope determine in JavaScript?

    <p>Scope determines where a variable is accessible.</p> Signup and view all the answers

    Which Angular decorator is used to define a service that can be injected into components?

    <p>@Injectable</p> Signup and view all the answers

    Which of the following best defines middleware in Node.js?

    <p>Functions executed during the lifecycle of an HTTP request.</p> Signup and view all the answers

    How can you implement lazy loading in an Angular application?

    <p>By loading modules asynchronously on demand.</p> Signup and view all the answers

    Which of the following is not correct syntax for writing output in JavaScript?

    <p>body.html()</p> Signup and view all the answers

    Which command is used to create a new Angular project with SCSS as the stylesheet format?

    <p>ng new projectName --style=scss</p> Signup and view all the answers

    What is the correct shorthand for setting a border to 4px, dotted, and red for the element?

    <p>P { border: 4px dotted red; }</p> Signup and view all the answers

    What is the purpose of Angular Guards?

    <p>To prevent access to certain components or routes.</p> Signup and view all the answers

    Which method is used to create a server in Node.js?

    <p>http.createServer()</p> Signup and view all the answers

    Which directive in Angular allows conditionally rendering a template based on a boolean expression?

    <p>*ngIf</p> Signup and view all the answers

    What are async and await used for in JavaScript?

    <p>async declares a function returning a promise.</p> Signup and view all the answers

    What does the error 'Cannot read property 'x' of undefined' typically indicate?

    <p>The variable is out of scope.</p> Signup and view all the answers

    In JavaScript, what will the result be when adding a number and a string, such as $5 + '8'$?

    <p>58</p> Signup and view all the answers

    What does DOM stand for in JavaScript?

    <p>A model representing HTML elements as objects.</p> Signup and view all the answers

    Which of the following statements about asynchronous programming in Node.js is true?

    <p>It allows operations to continue while waiting for an operation.</p> Signup and view all the answers

    What will be the output of the following JavaScript code? 'let x = 10; function test() { let x = 20; console.log(x); } test(); console.log(x);'

    <p>20, 10</p> Signup and view all the answers

    What type of values are returned from callbacks in JavaScript?

    <p>Values passed as arguments to other functions.</p> Signup and view all the answers

    In Angular, which feature allows communication between components?

    <p>Using services and decorators.</p> Signup and view all the answers

    Which statement accurately describes the use of package.json in Node.js?

    <p>It defines project metadata, dependencies, and scripts.</p> Signup and view all the answers

    What does the following code perform? 'try { throw "An error occurred"; } catch (e) { console.log(error); }'

    <p>Throws a ReferenceError</p> Signup and view all the answers

    Which of the following is NOT a legal variable name in JavaScript?

    <p>-firstname</p> Signup and view all the answers

    What does the @Component decorator do in Angular?

    <p>Marks a class as an Angular component</p> Signup and view all the answers

    In JavaScript, which of the following describes the data type of 'let x = 7.5'?

    <p>Number</p> Signup and view all the answers

    What will the following code output? 'for (var i = 0; i < 3; i++) { setTimeout(() => console.log(i), 1000); }'

    <p>3, 3, 3</p> Signup and view all the answers

    What will be the output of the following code? let array = [ 2, 7, 8]; array = ; console.log(array.length);

    <p>3</p> Signup and view all the answers

    What is the correct way to merge two objects in JavaScript?

    <p><code>{ …object1, …object2 }</code></p> Signup and view all the answers

    What will be the output of the function when it is called? function test(){ console.log(x); var x = 10; } test();

    <p>undefined</p> Signup and view all the answers

    What will be the output of the following code? let x = 1; if(true){ let x = 2; console.log(x); } console.log(x);

    <p>1, then 2</p> Signup and view all the answers

    What will be the output of the following code, and how does the makeCounter() function work? function makeCounter() { let count = 0; return { increment: function() { count++; return count; }, decrement: function() { count--; return count; }, getCount: function() { return count; } }; } const counter = makeCounter(); console.log(counter.increment()); console.log(counter.increment()); console.log(counter.getCount()); console.log(counter.decrement());

    <p>1, 2, 2, 1</p> Signup and view all the answers

    What will be the output of the following code? for (var i = 0; i < 3; i++) { setTimeout(function() { console.log(i); }, 100); }

    <p>3, 3, 3</p> Signup and view all the answers

    What will the following code output? async function getData() { return await Promise.resolve('I made it!'); } const data = getData(); console.log(data);

    <p>Promise {: &quot;I made it!&quot;}</p> Signup and view all the answers

    Which of the following is a valid way to define an anonymous function?

    <p>const greet = function() { console.log(&quot;Hello!&quot;); };</p> Signup and view all the answers

    How can you create an Immediately Invoked Function Expression (IIFE)?

    <p>(function() { console.log(&quot;I am executed!&quot;); })();</p> Signup and view all the answers

    What does the following code do? setTimeout(() => { console.log("Hello"); }, 0); console.log("World");

    <p>It logs &quot;World&quot; then &quot;Hello&quot;.</p> Signup and view all the answers

    Study Notes

    HTML

    • Changing text color: Use the color attribute within the <span> or similar HTML element. Example: <span style="color:red;">This text is red.</span>.
    • Class attribute: Groups elements for styling. It's useful for applying the same style to multiple elements.
    • Displaying tables: Use the <table> tag. Inside, use <tr> (table row) and <td> (table data) for individual entries.
    • Marquee: A <marquee> tag creates scrolling text or images.
    • Required HTML parts: <html>, <head>, <body>.
    • HTML attribute syntax: Use the form attribute="value" within an HTML element tag. Example: <img src="image.jpg" alt="description">

    CSS

    • CSS display properties: block, inline, flex, grid, none.
    • rgba alpha: The alpha (A) value in rgba(R, G, B, A) sets the transparency of the color.
    • Margin shorthand property: margin: top right bottom left; sets top, right, bottom, and left margins respectively (in that order)
    • Text formatting: font-family, font-size, color, text-align.
    • Hiding elements: Use display: none; or visibility: hidden; (they have different visual effects).
    • CSS overflow: Controls content clipping or scrolling.
    • Media query syntax: @media screen and (max-width: 800px) {} (Note the @).
    • Form submission link: Set target="_blank" on the link to open it in a new tab.
    • Border shorthand: border: 4px dotted red; sets border width, style, and color.
    • Hover effect on links: a:hover { background-color: red; }

    JavaScript

    • Data types: Number, String, Object, Array, Undefined, Boolean, Null, Symbol, BigInt.
    • == vs. ===: == compares values only, === compares both value and type.
    • Scope and scope chain: Scope defines variable accessibility, scope chain connects scopes.
    • Callbacks: Functions passed as arguments to other functions.
    • DOM (Document Object Model): A tree-like representation of HTML elements in JavaScript.
    • async/await: async function returns a promise, await suspends execution until the promise resolves.
    • Arrow functions: Functions defined using =>
    • var, let, const: var has function scope, let and const have block scope. let and const are hoisted but have a different declaration order.
    • Output methods in JavaScript: window.alert(), console.log(), document.write(), and body.html() (using document.body.innerHTML)
    • Examples of invalid variable names: those starting with a hyphen or underscore (other than $ are valid)

    Node.js

    • Node.js threading: Node.js is single-threaded; it uses multiple threads internally for I/O operations.
    • npm: The Node Package Manager (npm) manages JavaScript libraries in Node.js.
    • Middleware (Node.js): Functions that run during HTTP requests lifecycle.
    • Event loop: The core of Node.js which handles non-blocking operations.
    • package.json: Configuration file for project metadata, dependencies, and scripts.
    • Child processes: Independent processes for handling tasks.
    • Master/Slave clusters: A cluster setup where a master process distributes tasks.
    • Server creation: Use http.createServer().
    • Asynchronous programming: allows other operations to continue while waiting.
    • Request body parsing middleware: body-parser
    • Express next() function: Passes control to next middleware function.
    • JWT parts: JWT has Header, Payload, and Signature.
    • JWT storage: Secure in cookies (with HttpOnly and Secure flags).
    • JWT library: jsonwebtoken.

    Angular

    • Angular features: MVC (Model-View-Controller) architecture, two-way data binding, dependency injection.
    • Component: Smallest UI building block in Angular, with a template and logic.
    • Angular router: Manages navigation.
    • Data passing between components: Angular uses services, @Input, and @Output decorators.
    • Lazy loading: Loads modules or components when necessary for performance.
    • Angular lifecycle hooks: Methods executed at specific points in a component's lifecycle.
    • Angular guards: Protect routes from unauthorized access.
    • @Component decorator: Marks a class as an Angular component.
    • Conditional CSS classes: Use [class].
    • Error "Cannot read property 'x' of undefined": Variable may be undeclared, uninitialized, or out of scope.
    • HTTP requests inspection: Chrome DevTools Network tab.
    • 404 error: Indicates incorrect API endpoint URL.
    • Binding properties: Use square brackets: [property]="value".
    • SCSS Angular creation: use ng new my-app --style=scss
    • @Injectable() decorator: Marks a class for dependency injection (used for services)
    • Conditional template inclusion: *ngIf, *ngSwitch

    General JavaScript concepts (from the questions)

    • Syntax errors: Check for correct function calls, variable naming, and data types (e.g., using 'string' instead of "string" for string literals)
    • Variable hoisting: var declarations are moved to the top of their scope, let and const are not.
    • try...catch blocks: The catch block needs an error variable (err) for safe error handling, and console.log(error) is incorrect; use console.log(err)
    • Function scope vs block scope: Use let and const inside blocks for localized variables.
    • Incorrect if structure: Review boolean expressions in your conditionals.
    • Immutability (general): Reassignment of variables, for example, let arr = [1, 2, 3]; arr = 42 will create issues.

    Studying That Suits You

    Use AI to generate personalized quizzes and flashcards to suit your learning preferences.

    Quiz Team

    Description

    Test your knowledge on essential HTML and CSS concepts with this quiz! From understanding the 'class' attribute to manipulating display properties, this quiz covers key topics that every web developer should know. Challenge yourself and see how well you can demonstrate your skills!

    More Like This

    CSS Syntax and HTML Basics
    6 questions
    HTML Alignment Attributes
    10 questions
    HTML CSS Styles Overview
    16 questions
    Use Quizgecko on...
    Browser
    Browser