🚀 Levoric Learn v2.1.1: Improved tutorials, faster navigation, and more. Learn more

Introduction to <body>

The <body>element is a fundamental part of any HTML document and it represents the main content area of a webpage, containing all the visible elements that users interact with, such as text, <images>, <videos>, <links>, and more. There can only be one <body>element per HTML document, and it typically appears after the <head>section.

Copy to clipboard

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>Vibrant Modern Layout</title>
        <link href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700&display=swap" rel="stylesheet">
        <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
        <link rel="stylesheet" href="styles.css">
    </head>
    
    <body>
        <header class="header">
            <nav class="navbar">
                <a href="#" class="logo">MyWebsite</a>
                <button class="menu-toggle" aria-label="Open Menu"><i class="fas fa-bars"></i></button>
                <ul class="nav-links">
                    <li><a href="#">Home</a></li>
                    <li><a href="#">About Us</a></li>
                    <li><a href="#">Services</a></li>
                    <li><a href="#">Portfolio</a></li>
                    <li><a href="#">Contact</a></li>
                </ul>
            </nav>
        </header>
    
        <div class="content-container">
            <section class="introduction">
                <h1>Welcome to MyWebsite</h1>
                <p>Your one-stop destination for modern web design. 
                We specialize in creating responsive, user-friendly websites that enhance your online presence.
                 Our team of experienced designers and developers is dedicated to bringing your vision to life.</p>
                <a href="#" class="cta-button">Get Started</a>
            </section>
    
            <section class="features">
                <h2>Our Features</h2>
                <ul>
                    <li><strong>Responsive Design:</strong> Websites that look great on all devices, from desktops to smartphones.</li>
                    <li><strong>Custom Solutions:</strong> Tailored designs to meet your specific business needs.</li>
                    <li><strong>SEO Optimization:</strong> Improve your visibility on search engines with our SEO-friendly designs.</li>
                    <li><strong>Fast Loading:</strong> Optimized performance to provide a smooth user experience.</li>
                </ul>
            </section>
    
            <section class="contact-info">
                <h2>Contact Us</h2>
                <p>If you have any questions or would like to start a project, feel free to reach out to us.</p>
                <p>Email: info@mywebsite.com | Phone: (123) 456-7890</p>
            </section>
        </div>
    
        <footer class="footer">
            <div class="footer-content">
                <div class="footer-about">
                    <h3>About MyWebsite</h3>
                    <p>We are a creative agency focused on delivering high-quality web designs and solutions. Our mission is to help businesses thrive in the digital landscape.</p>
                </div>
                <div class="footer-links">
                    <h3>Quick Links</h3>
                    <ul>
                        <li><a href="#">Privacy Policy</a></li>
                        <li><a href="#">Terms of Service</a></li>
                        <li><a href="#">FAQ</a></li>
                    </ul>
                </div>
                <div class="footer-social">
                    <h3>Follow Us</h3>
                    <div class="social-icons">
                        <a href="#" class="social-icon"><i class="fab fa-facebook-f"></i> Facebook</a>
                        <a href="#" class="social-icon"><i class="fab fa-twitter"></i> Twitter</a>
                        <a href="#" class="social-icon"><i class="fab fa-linkedin-in"></i> LinkedIn</a>
                        <a href="#" class="social-icon"><i class="fab fa-instagram"></i> Instagram</a>
                    </div>
                </div>
            </div>
            <div class="footer-bottom">
                <p>© 2024 MyWebsite. All rights reserved.</p>
            </div>
        </footer>
    </body>
    </html>
    
Copy to clipboard
/* General Reset */
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}

body {
font-family: 'Roboto', sans-serif;
background: linear-gradient(135deg, #b0c2ff, #b181ff, #fad0c4, #ff9a9e);
color: #333;
display: flex;
flex-direction: column;
align-items: center;
min-height: 100vh;
margin: 0;
overflow-x: hidden;
background-size: 400% 400%;
animation: gradientBG 15s ease infinite;
}

@keyframes gradientBG {
0% {
background-position: 0% 50%;
}
50% {
background-position: 100% 50%;
}
100% {
background-position: 0% 50%;
}
}

/* Header Styles */
.header {
width: 100%;
background-color: rgba(255, 255, 255, 0.9);
backdrop-filter: blur(10px);
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
position: fixed;
top: 0;
left: 0;
z-index: 1000;
}

.navbar {
display: flex;
justify-content: space-between;
align-items: center;
padding: 15px 30px;
}

.logo {
font-size: 1.8rem;
font-weight: 700;
color: #ff6f61;
text-decoration: none;
}

.nav-links {
list-style: none;
display: flex;
gap: 20px;
transition: max-height 0.3s ease-out;
}

.nav-links a {
text-decoration: none;
color: #333;
font-weight: 500;
transition: color 0.3s ease;
}

.nav-links a:hover {
color: #ff6f61;
}

.menu-toggle {
display: none;
background: none;
border: none;
font-size: 1.5rem;
color: #333;
}

/* Centered Content Container */
.content-container {
background-color: #ffffff;
border-radius: 20px;
padding: 40px 30px;
box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
text-align: center;
max-width: 800px;
width: 90%;
margin-top: 120px; /* To avoid overlapping with header */
margin-bottom: 60px; /* For spacing above the footer */
animation: fadeIn 1s ease-in-out;
}

/* Animation for Content Fade-In */
@keyframes fadeIn {
from {
opacity: 0;
transform: translateY(20px);
}
to {
opacity: 1;
transform: translateY(0);
}
}

.introduction h1 {
font-size: 3rem;
color: #ff6f61;
margin-bottom: 20px;
}

.introduction p {
font-size: 1.2rem;
color: #555;
margin-bottom: 30px;
line-height: 1.8;
}

.features h2, .contact-info h2 {
font-size: 2.2rem;
color: #333;
margin-bottom: 20px;
}

.features ul {
text-align: left;
margin: 0 auto;
max-width: 600px;
color: #444;
line-height: 1.8;
}

.contact-info p {
font-size: 1.1rem;
color: #444;
line-height: 1.6;
}

/* Call-to-Action Button */
.cta-button {
display: inline-block;
padding: 15px 40px;
background-color: #ff6f61;
color: #ffffff;
border: none;
border-radius: 50px;
text-decoration: none;
font-size: 1.1rem;
font-weight: 500;
transition: background-color 0.3s ease, transform 0.3s ease;
box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.cta-button:hover {
background-color: #ff3b2e;
transform: scale(1.1);
}

/* Footer Styles */
.footer {
width: 100%;
background-color: #ff6f61;
padding: 50px 20px;
text-align: center;
box-shadow: 0 -2px 4px rgba(0, 0, 0, 0.1);
position: relative;
bottom: 0;
left: 0;
color: #ffffff;
}

.footer-content {
display: flex;
justify-content: space-between;
align-items: flex-start;
flex-wrap: wrap;
max-width: 1200px;
margin: 0 auto;
color: #ffffff;
}

.footer-about, .footer-links, .footer-social {
flex: 1;
padding: 20px;
min-width: 200px;
}

.footer-about h3, .footer-links h3, .footer-social h3 {
font-size: 1.5rem;
color: #ffffff;
margin-bottom: 15px;
}

.footer-about p {
font-size: 1rem;
color: #fde8e8;
line-height: 1.6;
}

.footer-links ul {
list-style: none;
padding: 0;
}

.footer-links ul li {
margin-bottom: 10px;
}

.footer-links ul li a {
text-decoration: none;
color: #fde8e8;
transition: color 0.3s ease;
}

.footer-links ul li a:hover {
color: #ffffff;
}

.footer-social .social-icons {
display: flex;
flex-direction: column;
align-items: center;
gap: 15px;
margin-top: 10px;
}

.social-icon {
display: block;
text-decoration: none;
color: #ffffff;
font-weight: 500;
transition: background-color 0.3s ease, transform 0.3s ease;
background-color: #ff3b2e;
padding: 15px;
border-radius: 10px;
width: 180px;
text-align: center;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.social-icon:hover {
background-color: #cc2a1f;
transform: translateY(-5px);
}

.footer-bottom {
margin-top: 20px;
}

.footer-bottom p {
color: #fde8e8;
font-size: 1rem;
}

/* Media Queries for Mobile Devices */
@media (max-width: 768px) {
.navbar {
padding: 15px;
}

.nav-links {
flex-direction: column;
gap: 10px;
position: absolute;
top: 100%;
left: 0;
background-color: rgba(255, 255, 255, 0.9);
width: 100%;
max-height: 0;
overflow: hidden;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.nav-links.active {
max-height: 200px;
padding: 10px 0;
}

.menu-toggle {
display: block;
}

.footer-content {
flex-direction: column;
align-items: center;
text-align: center;
}

.footer-about, .footer-links, .footer-social {
padding: 10px;
width: 100%;
}

.footer-social .social-icons {
flex-direction: row;
flex-wrap: wrap;
justify-content: center;
}
}

Copy to clipboard
// JavaScript for toggle menu on small screens
document.querySelector('.menu-toggle').addEventListener('click', function() {
    document.querySelector('.nav-links').classList.toggle('active');
});

Global Attributes

AttributesDescription
accesskeySpecifies a shortcut key to activate or focus an element.
autocapitalizeControls whether and how text input is automatically capitalized.
classSpecifies one or more class names for the element, allowing CSS styling and JavaScript manipulation.
contenteditableSpecifies whether the content of an element is editable or not.
contextmenuSpecifies a context menu for the element.
dirDefines the text direction. Possible values are "ltr" (left-to-right), "rtl" (right-to-left), and "auto".
draggableSpecifies whether an element is draggable. Possible values are "true" or "false".
enterkeyhintSpecifies the action label or icon to be shown for the enter key on virtual keyboards.
hiddenIndicates that the element is not yet, or is no longer, relevant. The browser does not display elements that have the `hidden` attribute set.
idSpecifies a unique identifier for the element.
inputmodeProvides a hint to browsers for which virtual keyboard configuration to use when editing this element or its descendants.
isAllows you to specify the type of custom element.
langSpecifies the language of the element's content.
nonceA cryptographic nonce ("number used once") that can be used by Content Security Policy (CSP) to determine whether or not a given fetch will be allowed to proceed.
partSpecifies the element’s part in the shadow DOM.
slotAssigns a slot in a shadow DOM shadow tree.
spellcheckIndicates whether the element is subject to spell checking.
styleProvides inline CSS styling for the element.
tabindexSpecifies the tab order of the element.
titleAdds extra information about the element, displayed as a tooltip when hovering over the element.
translateSpecifies whether the content of the element should be translated. Possible values are "yes" or "no".
HTML AttributesGlobal AttributesEvent Attributes
To view the full list
To view the full list
To view the full list
Chrome BrowsersMicrosoft Edge BrowserFirefox BrowsersSafari BrowserOpera Browser
<body>YesYesYesYes