Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to define a root layout component that wraps children in a <html> and <body>.
NextJS
export default function RootLayout({ children }) {
return (
<html lang=[1]>
<body>{children}</body>
</html>
)
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Omitting the lang attribute on the html tag.
Using an incorrect string for lang attribute.
✗ Incorrect
The root layout should set the lang attribute on the <html> tag, commonly "en" for English.
2fill in blank
mediumComplete the code to import global CSS styles in the root layout file.
NextJS
import [1]; export default function RootLayout({ children }) { return ( <html lang="en"> <body>{children}</body> </html> ) }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Trying to import CSS as a named import.
Omitting the file extension .css.
✗ Incorrect
In Next.js root layout, global CSS is imported with the path string './globals.css'.
3fill in blank
hardFix the error in the root layout component by completing the metadata export with the correct title string.
NextJS
export const metadata = {
title: [1],
description: 'My Next.js app'
};
export default function RootLayout({ children }) {
return (
<html lang="en">
<body>{children}</body>
</html>
)
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Omitting quotes around the string.
Using single quotes inconsistently.
✗ Incorrect
The title value must be a string literal with quotes, for example "My App".
4fill in blank
hardFill both blanks to add a <head> element with a <title> inside the root layout.
NextJS
export default function RootLayout({ children }) {
return (
<html lang="en">
<head>[1]<title>My App</title>[2]</head>
<body>{children}</body>
</html>
)
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Not wrapping multiple elements inside head.
Using invalid tags inside head.
✗ Incorrect
Use empty fragment tags <> and > to wrap multiple elements inside head if needed.
5fill in blank
hardFill all three blanks to create a root layout that imports global CSS, sets metadata, and renders children inside <html> and <body>.
NextJS
import [1]; export const metadata = { title: [2], description: 'Example app' }; export default function RootLayout({ children }) { return ( <html lang="en"> <body>[3]</body> </html> ) }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Not importing CSS correctly.
Missing quotes around title.
Not rendering children inside body.
✗ Incorrect
Import global CSS with './globals.css', set title as a string, and render children inside body.