Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <title>Sections</title>
- <style>
- #content {
- width: 1000px;
- }
- #content div {
- float: left;
- width: 300px;
- height: 300px;
- margin: 2em;
- background: #5555ff;
- text-align: center;
- }
- #content div p {
- color: white;
- margin: 6em 3em 6em 3em;
- }
- </style>
- </head>
- <div id="content">
- </div>
- <body onload="create(['Section 1', 'Section 2', 'Section 3', 'Section 4']);">
- <script>
- function create(words) {
- for (let word of words) {
- let div = document.createElement('div');
- let paragraph = document.createElement('p');
- paragraph.textContent = word;
- div.appendChild(paragraph);
- let contentDiv = document.getElementById('content');
- contentDiv.appendChild(div);
- }
- }
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement