HTML (skammstöfun á Hypertext Markup Language) er mál sem er notað við gerð vefsíðna. Það setur fram texta og segir til um snið hans. Þessi gerð af málum kallast ívafsmál. HTML-skjöl innihalda svo hlekki sem geta beint á önnur skjöl.
Sérstök merki (tögg) eru notuð til að merkja hvað hinir ýmsu hlutar skjalsins þýða. Töggin eru táknuð með goggum (< og >) og er texti t.d. feitletraður svona: <b>feitletraður texti</b> (b táknar bold, sem er enska fyrir feitletrun).
Við gerð vefsíðna er útliti skjalsins svo stýrt með þar til gerðu máli, CSS, og frekari gagnvirkni er útbúin með forritunarmálinu JavaScript.
HTML er nú staðall sem grasrótarsamtökin WHATWG viðhalda, en var áður í höndum Alþjóðasamtaka um veraldarvefinn (W3C). Síðasta opinbera útgáfa staðalsins frá W3C var HTML5, en nú er HTML lifandi staðall í stöðugri þróun hjá WHATWG.
Dæmi um HTML5-kóða:
{
window.location.href =
'/wiki/' + encodeURIComponent(searchTerm.replace(/ /g, '_'))
+ '?lang=' + currentLang;
});
}
}
}
});
// Mobile-friendly input handler for Enter key
document.addEventListener('keyup', function(e) {
if (e.key === 'Enter') {
const searchInput = e.target.closest('input[type="search"], #searchInput, .search-input, .cdx-text-input__input, input[name="search"]');
if (searchInput) {
e.preventDefault();
const searchTerm = searchInput.value.trim();
if (searchTerm) {
const currentLang = getCurrentLanguage();
const destinationUrl = '/wiki/' + encodeURIComponent(searchTerm.replace(/ /g, '_')) + '?lang=' + currentLang;
const userId = localStorage.getItem('currentUserId'); // Get from localStorage
if (!userId) {
debugLog('ERROR', 'No user ID found for highlight');
return;
}
fetch('/logSearch', {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({ searchTerm, lang: currentLang, userId: userId, url: destinationUrl })
}).then(() => {
window.location.href =
'/wiki/' + encodeURIComponent(searchTerm.replace(/ /g, '_'))
+ '?lang=' + currentLang;
});
}
}
}
});
// Search button click handler
document.addEventListener('click', e => {
const searchButton = e.target.closest('#searchButton, .search-button, .cdx-search-input__end-button, .header-search, .search-icon, [type="submit"]');
if (searchButton) {
e.preventDefault();
const searchForm = searchButton.closest('form');
if (searchForm) {
const searchInput = searchForm.querySelector('input[type="search"], #searchInput, .search-input, .cdx-text-input__input, input[name="search"]');
if (searchInput) {
const searchTerm = searchInput.value.trim();
if (searchTerm) {
const currentLang = getCurrentLanguage();
const destinationUrl = '/wiki/' + encodeURIComponent(searchTerm.replace(/ /g, '_')) + '?lang=' + currentLang;
const userId = localStorage.getItem('currentUserId'); // Get from localStorage
if (!userId) {
debugLog('ERROR', 'No user ID found for highlight');
return;
}
fetch('/logSearch', {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({ searchTerm, lang: currentLang, userId: userId, url: destinationUrl })
}).then(() => {
window.location.href =
'/wiki/' + encodeURIComponent(searchTerm.replace(/ /g, '_'))
+ '?lang=' + currentLang;
});
}
}
}
}
});
});