Jun 26, 2024
<!DOCTYPE html>
: Defines the document type.<html>
: Root element.<head>
: Contains meta-information.<title>
: Title of the document.<body>
: Contains the content.<h1>
to <h6>
: Heading tags<p>
: Paragraph<hr>
: Horizontal rule<a>
: Anchor (links)<ul>
, <ol>
, <li>
: Lists (unordered, ordered)<img>
: Images<table>
, <tr>
, <td>
: Tables<form>
, <input>
, <button>
: Forms<!DOCTYPE html>
<html>
<head>
<title>Upcoming Events</title>
</head>
<body>
<h1>Upcoming Events</h1>
<p>Don’t miss any of your important events. Here are the important events you have registered for:</p>
<p>Free entry, free food, pets are not allowed.</p>
<img src='image.jpg' alt='Event Image'>
</body>
</html>
style
attribute in HTML tags.<style>
tag in the <head>
section.<link rel='stylesheet' href='styles.css'>
in the <head>
section.p { color: red; }
.className {}
#idName {}
color
: Text colorbackground-color
: Background colorwidth
, height
: Dimensionspadding
, margin
: Spacingborder
: Border around elementsdisplay: flex
: Defines a flex containerflex-direction
: Row or columnjustify-content
: Aligns items horizontallyalign-items
: Aligns items verticallyvar
, let
, const
+
, -
, *
, /
==
, ===
, !=
, !==
, >
, <
function
keywordfunction add(a, b) {
return a + b;
}
console.log(add(3, 4)); // Outputs: 7
if
, else
for
, while
loopsswitch
statementsdocument.getElementById('id')
document.querySelector('.class')
element.innerHTML
, element.style
onclick
, onmouseover
, onchange
element.addEventListener('event', function)
<!DOCTYPE html>
<html>
<head>
<title>My Web Page</title>
<link rel='stylesheet' href='styles.css'>
</head>
<body>
<h1>Hello, World!</h1>
<p>This is a paragraph.</p>
<button id='clickMe'>Click Me</button>
<script src='script.js'></script>
</body>
</html>
body {
background-color: #f0f0f0;
}
h1 {
color: #333;
}
p {
color: #666;
}
button {
background-color: #008cba;
color: white;
border: none;
padding: 10px 20px;
cursor: pointer;
}
button:hover {
background-color: #005f5f;
}
document.getElementById('clickMe').addEventListener('click', function() {
alert('Button Clicked!');
});
@media (max-width: 600px) {
body {
background-color: lightblue;
}
}
.container {
display: flex;
justify-content: space-between;
align-items: center;
}
.item {
flex: 1;
}
flex-direction: row;
flex-direction: column;
function greet(name) {
console.log('Hello, ' + name + '!');
}
greet('Alice');
(function() { /* code */ })()
<form id='eventForm'>
<input type='text' id='eventName' placeholder='Event Name'>
<button type='submit'>Add Event</button>
</form>
<ul id='eventList'></ul>
document.getElementById('eventForm').addEventListener('submit', function(e) {
e.preventDefault();
var eventName = document.getElementById('eventName').value;
if (eventName) {
var li = document.createElement('li');
li.textContent = eventName;
document.getElementById('eventList').appendChild(li);
document.getElementById('eventName').value = '';
} else {
alert('Please enter an event name.');
}
});