Minulý týždeň dostala tvoja stránka obsah. Dnes dostane vzhľad — a form, ktorý o pár týždňov napojíme na PHP. Všetko potrebné je na tejto stránke; odkazy (links) na W3Schools sú navyše, keď chceš viac.
Last week your page got content. Today it gets its looks — and a form that we will connect to PHP in a few weeks. Everything you need is on this page; the W3Schools links are extra, for when you want more.
TeóriaTheory
Čo je CSS a ako ho pripojiť
HTML hovorí, čo obsah je; CSS (Cascading Style Sheets) hovorí, ako má vyzerať. Štýl sa dá zapísať tromi spôsobmi: priamo do atribútu (attribute) style elementu (inline), do značky (tag) <style> v <head> stránky, alebo do samostatného súboru. My používame výhradne samostatný súbor css/style.css — jeden súbor oštýluje všetky stránky webu naraz a zmeny robíš na jednom mieste. Do <head> každej stránky patrí:
<link rel="stylesheet" href="css/style.css">
Viac: W3Schools: CSS How To
Selektory (selectors) na elementy
Pravidlo CSS má tvar selector { property: hodnota; }. Selector vyberá prvky (elements), na ktoré sa pravidlo použije. Najjednoduchší selector je názov tag — zasiahne všetky jej výskyty na všetkých stránkach, ktoré štýl pripájajú.
| Zápis | Čo vyberie |
|---|---|
h2 { } |
všetky headings h2 |
h1, h2 { } |
viac druhov elements naraz (čiarka) |
nav a { } |
len links vo vnútri nav (medzera = zanorenie) |
Viac: W3Schools: CSS Selectors
Trieda (class)
Class označuje ľubovoľnú skupinu elements, ktoré majú vyzerať rovnako — bez ohľadu na to, aké sú to tag. V HTML je to attribute class, v CSS sa selector class píše s bodkou. Jedna class môže byť na mnohých elements a jeden element môže mať viac class (oddelených medzerou): class="highlight aktualne".
Viac: W3Schools: The class Selector
id — a kedy použiť čo
id označuje jeden konkrétny element: každé id smie byť na stránke len raz. V CSS sa píše s mriežkou # #. Pravidlo palca: vzhľad rieš classes, id si nechaj pre jedinečné elements — zíde sa ti aj na kotvy v URL (form.html#contact) a o pár týždňov v JavaScripte, keď bude treba chytiť presne jeden element.
Viac: W3Schools: The id Selector
Box model
Každý element na stránke je obdĺžnik so štyrmi vrstvami: obsah → padding (vnútorný odstup) → border (rámik) → margin (vonkajší odstup od okolia). Keď niečo „nesedí o pár pixelov”, takmer vždy je to box model. Nakreslený si ho pozrieš v prehliadači cez F12 (nižšie).
Viac: W3Schools: CSS Box Model
Pozicovanie
Normálne idú elements za sebou, ako sú zapísané v HTML (position: static). Ostatné hodnoty to menia:
| Hodnota | Čo robí |
|---|---|
relative |
posunie element voči jeho pôvodnému miestu a vytvorí „kotvisko” pre potomkov |
absolute |
umiestni element presne voči najbližšiemu rodičovi s position: relative |
fixed |
pripne element k oknu prehliadača — ideálne na menu, ktoré má byť stále viditeľné |
Obsah stránky sa centruje obmedzením šírky: max-width + margin: 0 auto (Ukážka 2).
Viac: W3Schools: CSS Position
Pseudotriedy :hover a :focus
Pseudotrieda štýluje stav element: :hover platí, keď je nad element myš, :focus, keď je pole (field) form aktívne (klikol si doň alebo si sa doň dostal tabulátorom). Práve nimi stránka „ožije” — a :focus je dôležitý aj pre prístupnosť: používateľ vidí, kde práve píše.
Viac: W3Schools: CSS Pseudo-classes
Form
Form zbiera údaje od návštevníka. Dve veci si zapamätaj už teraz:
labelhovorí, čo do field patrí; jeho attributeforukazuje naidfield, takže klik na popisok aktivuje field.nameje meno, pod ktorým údaj odíde zo stránky. O pár týždňov si tieto údaje vyzdvihneme v PHP presne podľaname, preto nesmie chýbať pri žiadnom field. Píše sa malými písmenami, bez diakritiky a bez medzier:since.valueje hodnota, ktorá odíde. Pri textovom field je to text, ktorý používateľ napísal. Prioption,radioacheckboxju určuješ ty attributevalue.
method="get" pripája odoslané údaje do URL: po odoslaní si adresný riadok pozri, svoje dáta tam uvidíš. Bežné typy fields: text, email, number, date, select (rozbaľovací zoznam, select), radio (jedna možnosť z viacerých, skupina má spoločné name), checkbox (skupina, z ktorej sa dá vybrať viac, má name s hranatými zátvorkami: interest[]), textarea, tlačidlo (button) submit. Celý form je v Ukážke 3.
Viac: W3Schools: HTML Forms
Preskúmaj si CSS v prehliadači (F12)
Stlač F12 a na karte Elements (Chrome/Edge) či Inspector (Firefox) klikni na ľubovoľný element: vpravo vidíš všetky pravidlá, ktoré naň platia; prečiarknuté sú tie, ktoré prehralo silnejšie pravidlo, a pri každom je napísané, z ktorého súboru a riadka prišlo. Dole nájdeš nakreslený box model element so skutočnými hodnotami. Toto je tvoj hlavný nástroj na ladenie CSS.
Najčastejšie chyby a čo znamenajú
| Čo vidíš | Príčina | Riešenie |
|---|---|---|
| stránka je bez štýlov | zlá cesta v <link> |
href="css/style.css", súbor je v priečinku css |
| jedno pravidlo neplatí | preklep v selector; pri class chýba bodka, pri id grid | porovnaj názov v HTML a v CSS, v F12 pozri, či sa pravidlo pri element ukazuje |
| neplatí nič od určitého riadka nižšie | chýba ; alebo } |
skontroluj riadok nad miestom, odkiaľ štýly neplatia |
| pravidlo je v F12 prečiarknuté | prebilo ho iné pravidlo | v F12 je víťazné pravidlo nad ním |
| pripnuté menu prekrýva začiatok stránky | position: fixed vyberie menu z bežného poradia |
body { padding-top: 60px; } |
element s position: absolute je v rohu celej stránky |
rodič nemá position: relative |
pridaj ho rodičovi |
| klik na popisok neaktivuje field | for v label nesedí s id field |
oba musia byť rovnaké |
| údaj z field po odoslaní nie je v adresnom riadku | field nemá name |
doplň name |
| v skupine radio sa dá vybrať viac možností | možnosti majú rôzne name |
celá skupina má rovnaké name |
| image je vo Five Server, ale na sigma chýba | pretiahnutý súbor sa nenahráva sám | Upload Folder |
| po zmene CSS vidíš v prehliadači starý vzhľad | prehliadač si pamätá starý súbor | Ctrl + F5 |
What CSS is and how to attach it
HTML says what the content is; CSS (Cascading Style Sheets) says how it should look. Styles can be written in three places: directly in an element’s style attribute (inline), in a <style> tag in the page head, or in a separate file. We use a separate file css/style.css only — one file styles all pages of the site and you make changes in one place. The head of every page gets:
<link rel="stylesheet" href="css/style.css">
More: W3Schools: CSS How To
Element selectors
A CSS rule has the form selector { property: value; }. The selector picks the elements the rule applies to. The simplest selector is a tag name — it hits all its occurrences on every page that attaches the stylesheet.
| Notation | What it selects |
|---|---|
h2 { } |
all h2 headings |
h1, h2 { } |
several kinds of elements at once (comma) |
nav a { } |
only links inside nav (space = nesting) |
More: W3Schools: CSS Selectors
Class
A class marks any group of elements that should look the same — no matter what tags they are. In HTML it is the class attribute, in CSS the class selector is written with a dot. One class can be on many elements and one element can have several classes (separated by spaces): class="highlight aktualne".
More: W3Schools: The class Selector
The id — and when to use which
An id marks one specific element: each id may appear on a page only once. In CSS it is written with a hash #. Rule of thumb: style with classes, keep id for unique elements — it is also useful for anchors in the URL (form.html#contact) and in a few weeks in JavaScript, when you need to grab exactly one element.
More: W3Schools: The id Selector
The box model
Every element on a page is a rectangle with four layers: content → padding (inner spacing) → border → margin (outer spacing from the surroundings). When something is “off by a few pixels”, it is almost always the box model. You will look at it drawn in the browser via F12 (below).
More: W3Schools: CSS Box Model
Positioning
Normally elements follow each other as written in the HTML (position: static). The other values change that:
| Value | What it does |
|---|---|
relative |
shifts the element relative to its original place and creates an “anchor” for descendants |
absolute |
places the element precisely relative to the nearest parent with position: relative |
fixed |
pins the element to the browser window — ideal for a menu that should stay visible |
Page content is centred by limiting its width: max-width + margin: 0 auto (Example 2).
More: W3Schools: CSS Position
The :hover and :focus pseudo-classes
A pseudo-class styles the state of an element: :hover applies when the mouse is over it, :focus when a form field is active (you clicked into it or reached it with Tab). This is what brings a page to life — and :focus also matters for accessibility: the user sees where they are typing.
More: W3Schools: CSS Pseudo-classes
The form
A form collects data from the visitor. Remember two things right away:
labelsays what belongs in a field; itsforattribute points to the field’sid, so clicking the label activates the field.nameis the name under which the value leaves the page. In a few weeks we will pick these values up in PHP exactly by theirname, so no field may be missing one. It is written in lowercase, without accents and without spaces:since.valueis the value that is sent. For a text field it is the text the user typed. Foroption,radioandcheckboxyou set it with thevalueattribute.
method="get" appends the submitted data to the URL: after submitting, look at the address bar and you will see your data there. Common field types: text, email, number, date, select (drop-down), radio (one option of several; the group shares one name), checkbox (a group where several can be ticked has a name with square brackets: interest[]), textarea, a submit button. The whole form is in Example 3.
More: W3Schools: HTML Forms
Explore CSS in the browser (F12)
Press F12 and on the Elements tab (Chrome/Edge) or Inspector (Firefox) click any element: on the right you see all the rules that apply to it; the crossed-out ones lost to a stronger rule, and each shows which file and line it came from. Below you will find the element’s box model drawn with real values. This is your main tool for debugging CSS.
The most common errors and what they mean
| What you see | Cause | Fix |
|---|---|---|
| the page is unstyled | a wrong path in the <link> |
href="css/style.css", the file is in the css folder |
| one rule does not apply | a typo in the selector; the dot is missing for a class, the hash for an id | compare the name in the HTML and in the CSS; in F12 check whether the rule shows for the element |
| nothing applies from a certain line down | a ; or } is missing |
check the line above the place where the styles stop applying |
| a rule is crossed out in F12 | another rule overrode it | in F12 the winning rule is above it |
| the pinned menu covers the start of the page | position: fixed takes the menu out of the normal order |
body { padding-top: 60px; } |
an element with position: absolute is in the corner of the whole page |
the parent has no position: relative |
add it to the parent |
| clicking a label does not activate the field | for in the label does not match the field’s id |
both must be the same |
| a field’s value is not in the address bar after submitting | the field has no name |
add a name |
| several options can be selected in a radio group | the options have different names |
the whole group shares one name |
| the image shows in Five Server but is missing on sigma | a dragged file is not uploaded by itself | Upload Folder |
| you see the old look in the browser after changing the CSS | the browser remembers the old file | Ctrl + F5 |
UkážkyExamples
Ukážka 1: selectors, class a id
h2 { color: #a3274f; } /* všetky headings h2 */
h1, h2 { font-family: Georgia, serif; } /* viac selectors naraz */
nav a { text-decoration: none; } /* len links vo vnútri nav */
.highlight { background-color: #f3e1e8; } /* class: bodka */
#contact { border-top: 3px solid #a3274f; } /* id: grid */
<p class="highlight">Dôležitý paragraph.</p>
<section id="contact"> ... </section>
Ukážka 2: box model, pozicovanie a centrovanie
img {
padding: 4px; /* odstup obsahu od rámika */
border: 2px solid #a3274f; /* rámik */
margin: 16px; /* odstup od okolitých elements */
max-width: 100%; /* image nepretečie mimo stránku */
}
nav { position: fixed; top: 0; left: 0; right: 0; }
body { padding-top: 60px; } /* aby pripnuté menu neprekrylo obsah */
.section { position: relative; } /* kotvisko */
.section .stitok { position: absolute; top: 8px; right: 8px; }
main { max-width: 800px; margin: 0 auto; } /* centrovanie obsahu */
nav a:hover { background-color: #a3274f; color: white; }
input:focus, textarea:focus { outline: 2px solid #a3274f; }
Ukážka 3: form so všetkými bežnými poľami
Form je registrácia lezca na lezeckej stene. Všimni si, že každé field má name, každý label má for s id svojho field a každá možnosť má value.
<form method="get" action="">
<label for="name">Meno a priezvisko</label>
<input type="text" id="name" name="name" required>
<label for="email">E-mail</label>
<input type="email" id="email" name="email" required>
<label for="since">Leziem od roku</label>
<input type="number" id="since" name="since" min="1950" max="2026">
<label for="date">Dátum prvej návštevy</label>
<input type="date" id="date" name="date">
<label for="grade">Najvyššia vylezená obťažnosť</label>
<select id="grade" name="grade" required>
<option value="">-- vyber --</option>
<option value="5a">5a (V)</option>
<option value="5c">5c (VI)</option>
<option value="6a">6a (VI+)</option>
<option value="6b">6b (VII)</option>
</select>
<fieldset>
<legend>Štýl lezenia</legend>
<input type="radio" id="style_toprope" name="style" value="toprope" checked>
<label for="style_toprope">s horným istením</label>
<input type="radio" id="style_lead" name="style" value="lead">
<label for="style_lead">s dolným istením</label>
<input type="radio" id="style_boulder" name="style" value="boulder">
<label for="style_boulder">bouldering</label>
</fieldset>
<fieldset>
<legend>Mám záujem o</legend>
<input type="checkbox" id="interest_course" name="interest[]" value="course">
<label for="interest_course">kurz pre začiatočníkov</label>
<input type="checkbox" id="interest_rental" name="interest[]" value="rental">
<label for="interest_rental">požičanie výstroja</label>
</fieldset>
<input type="checkbox" id="consent" name="consent" value="yes" required>
<label for="consent">Súhlasím s prevádzkovým poriadkom</label>
<label for="message">Správa</label>
<textarea id="message" name="message" rows="3"></textarea>
<button type="submit">Registrovať</button>
</form>
Takto vyzerá kód z ukážky v prehliadači. Vyskúšaj: klikni do field (:focus), klikni na popisok, prejdi myšou na button (:hover), vyplň, stlač Registrovať a pozri si adresný riadok.
Po odoslaní sa pozri do adresného riadka. Presne tieto dvojice name=hodnota si o pár týždňov prečíta PHP:
form.html?name=Jana+Nováková&email=jana@example.com&since=2021&date=2026-10-13&grade=6a&style=lead&interest%5B%5D=course&consent=yes&message=
| Field | Čo odíde |
|---|---|
| text, e-mail, číslo, dátum, textarea | to, čo používateľ napísal |
select |
value vybranej možnosti (6a), nie text, ktorý vidí človek („6a (VI+)“) |
radio |
value jedinej vybranej možnosti v skupine (lead) |
skupina checkbox |
value každého zaškrtnutého; znaky %5B%5D v adrese sú zakódované zátvorky [] |
jeden checkbox |
jeho value (ano), keď je zaškrtnutý; inak neodíde nič |
Ukážka 4: prompt pre AI na dvojstránkový web
Web nepíšeš ručne, zadáš ho AI. Dobrý prompt presne povie, čo chceš dostať:
Vytvor mi jednoduchý web v HTML5 v slovenčine (lang="sk", kódovanie UTF-8),
dve stránky a jeden samostatný súbor so štýlmi. Bez JavaScriptu a bez
frameworkov (žiadny Bootstrap).
Štruktúra súborov, presne takto:
- index.html
- form.html
- css/style.css (jediné miesto so štýlmi, žiadne inline štýly ani <style>)
- img/photo.jpg (image dodám sám)
index.html obsahuje:
- header s heading h1 a vodorovné menu s links na index.html a form.html
(menu je rovnaké na oboch stránkach),
- aspoň dve section s headings h2 a paragraphs textu, jedna section má id,
- image img/photo.jpg s attribute alt,
- footer s menom a rokom.
form.html obsahuje to isté menu a form <form method="get" action="">
(zatiaľ bez spracovania, neskôr ho napojíme na PHP). Fields:
- textové field (meno), e-mail (type="email"), číslo (type="number" s min
a max), dátum (type="date"),
- select s aspoň tromi možnosťami; prvá možnosť je
<option value="">-- vyber --</option>,
- skupinu troch radio tlačidiel vo <fieldset> s <legend>, jedno má checked,
- skupinu dvoch checkboxov vo <fieldset> s <legend>, z ktorých sa dá vybrať
viac,
- jeden samostatný checkbox na súhlas s value="yes",
- textarea na správu,
- odosielacie button <button type="submit">.
Pravidlá pre KAŽDÉ field form (kvôli PHP):
- attribute name: malé písmená, bez diakritiky a bez medzier, slová spojené
podčiarkovníkom (napr. since); každé name je iné,
- attribute id a vlastný <label for="..."> s tým istým id,
- každá možnosť (option, radio, checkbox) má attribute value s krátkou
hodnotou bez diakritiky a bez medzier,
- radio v skupine majú rovnaké name,
- skupina checkboxov má name s hranatými zátvorkami (napr. interest[]).
CSS v css/style.css: čitateľné písmo, obsah s obmedzenou šírkou centrovaný cez
max-width a margin auto, farebne odlíšené headings, menu položky vedľa seba,
vzhľad form (fields pod sebou, label nad field, odsadenia), image nesmie
pretiecť mimo stránku. Použi selectors na elementy, aspoň jednu class a aspoň
jeden id selector.
Do HTML aj CSS napíš krátke slovenské komentáre ku každému bloku, ktoré
vysvetlia, čo robí a prečo — učím sa z nich.
Téma webu: [DOPLŇ tému svojho projektu]
Prečo je prompt napísaný práve takto:
- presná štruktúra súborov:
css/aimg/priečinky ťa učia poriadok a URL na sigma bude čistá, - žiadne inline štýly: všetko CSS je na jednom mieste — tak sa dá meniť a ladiť,
namealabelpri každom field: form o pár týždňov napojíme na PHP a beznameby údaje neprišli,valuepri každej možnosti: PHP dostanevalue, nie text, ktorý vidí človek,- komentáre v kóde: kód vieš prečítať a vysvetliť — to budeš robiť pri obhajobe,
- téma projektu: každý má iný web.
Keď výsledok nesedí, celý prompt nepíš znova. Napíš AI, čo presne treba opraviť, napríklad: „Menu nie je vedľa seba, oprav CSS.”
Example 1: selectors, a class and an id
h2 { color: #a3274f; } /* all h2 headings */
h1, h2 { font-family: Georgia, serif; } /* several selectors at once */
nav a { text-decoration: none; } /* only links inside nav */
.highlight { background-color: #f3e1e8; } /* class: a dot */
#contact { border-top: 3px solid #a3274f; } /* id: a hash */
<p class="highlight">An important paragraph.</p>
<section id="contact"> ... </section>
Example 2: box model, positioning and centring
img {
padding: 4px; /* space between content and border */
border: 2px solid #a3274f; /* the border */
margin: 16px; /* space from surrounding elements */
max-width: 100%; /* the image must not overflow the page */
}
nav { position: fixed; top: 0; left: 0; right: 0; }
body { padding-top: 60px; } /* so the pinned menu does not cover content */
.sekcia { position: relative; } /* the anchor */
.sekcia .stitok { position: absolute; top: 8px; right: 8px; }
main { max-width: 800px; margin: 0 auto; } /* centring the content */
nav a:hover { background-color: #a3274f; color: white; }
input:focus, textarea:focus { outline: 2px solid #a3274f; }
Example 3: a form with all the common fields
The form is a climber registration at a climbing wall. Notice that every field has a name, every label has a for with the id of its field, and every option has a value.
<form method="get" action="">
<label for="name">Full name</label>
<input type="text" id="name" name="name" required>
<label for="email">E-mail</label>
<input type="email" id="email" name="email" required>
<label for="since">Climbing since (year)</label>
<input type="number" id="since" name="since" min="1950" max="2026">
<label for="date">Date of first visit</label>
<input type="date" id="date" name="date">
<label for="grade">Hardest grade climbed</label>
<select id="grade" name="grade" required>
<option value="">-- select --</option>
<option value="5a">5a (V)</option>
<option value="5c">5c (VI)</option>
<option value="6a">6a (VI+)</option>
<option value="6b">6b (VII)</option>
</select>
<fieldset>
<legend>Climbing style</legend>
<input type="radio" id="style_toprope" name="style" value="toprope" checked>
<label for="style_toprope">top rope</label>
<input type="radio" id="style_lead" name="style" value="lead">
<label for="style_lead">lead</label>
<input type="radio" id="style_boulder" name="style" value="boulder">
<label for="style_boulder">bouldering</label>
</fieldset>
<fieldset>
<legend>I am interested in</legend>
<input type="checkbox" id="interest_course" name="interest[]" value="course">
<label for="interest_course">a beginners' course</label>
<input type="checkbox" id="interest_rental" name="interest[]" value="rental">
<label for="interest_rental">gear rental</label>
</fieldset>
<input type="checkbox" id="consent" name="consent" value="yes" required>
<label for="consent">I agree with the wall rules</label>
<label for="message">Message</label>
<textarea id="message" name="message" rows="3"></textarea>
<button type="submit">Register</button>
</form>
This is what the code from the example looks like in the browser. Try it: click into a field (:focus), click a label, hover over the button (:hover), fill it in, press Register and look at the address bar.
After submitting, look at the address bar. Exactly these name=value pairs will be read by PHP in a few weeks:
form.html?name=Jana+Novakova&email=jana@example.com&since=2021&date=2026-10-13&grade=6a&style=lead&interest%5B%5D=course&consent=yes&message=
| Field | What is sent |
|---|---|
| text, e-mail, number, date, textarea | what the user typed |
select |
the value of the selected option (6a), not the text a person sees (“6a (VI+)”) |
radio |
the value of the one selected option in the group (lead) |
a group of checkbox |
the value of every ticked one; the characters %5B%5D in the address are the encoded brackets [] |
a single checkbox |
its value (ano) when it is ticked; otherwise nothing is sent |
Example 4: an AI prompt for a two-page website
You do not write the site by hand, you brief an AI. A good prompt says precisely what you want to get:
Create a simple two-page website in HTML5 (set lang to the page language,
UTF-8 encoding) with one separate stylesheet. No JavaScript and no frameworks
(no Bootstrap).
File structure, exactly like this:
- index.html
- form.html
- css/style.css (the only place with styles, no inline styles and no <style>)
- img/photo.jpg (I will supply the image)
index.html contains:
- a header with an h1 heading and a horizontal menu linking to index.html and
form.html (the same menu on both pages),
- at least two sections with h2 headings and paragraphs, one section has an id,
- the image img/photo.jpg with an alt attribute,
- a footer with my name and the year.
form.html contains the same menu and a form <form method="get" action="">
(no processing yet, we will connect it to PHP later). Fields:
- a text field (name), an e-mail (type="email"), a number (type="number"
with min and max), a date (type="date"),
- a select with at least three options; the first option is
<option value="">-- select --</option>,
- a group of three radio buttons in a <fieldset> with a <legend>, one has
checked,
- a group of two checkboxes in a <fieldset> with a <legend>, where several
can be ticked,
- one single checkbox for agreement with value="yes",
- a textarea for a message,
- a submit button <button type="submit">.
Rules for EVERY form field (because of PHP):
- a name attribute: lowercase, no accents, no spaces, words joined by an
underscore (e.g. since); every name is different,
- an id attribute and its own <label for="..."> with the same id,
- every option (option, radio, checkbox) has a value attribute with a short
value without accents and spaces,
- radios in a group share one name,
- a checkbox group has a name with square brackets (e.g. interest[]).
CSS in css/style.css: readable font, content width limited and centred with
max-width and margin auto, coloured headings, menu items side by side, form
styling (fields below each other, label above the field, spacing), the image
must not overflow the page. Use element selectors, at least one class and at
least one id selector.
Add short comments to both the HTML and the CSS for every block, explaining
what it does and why — I learn from them.
Website topic: [FILL IN your project topic]
Why the prompt is written this way:
- the exact file structure: the
css/andimg/folders teach you order and the URL on sigma stays clean, - no inline styles: all CSS is in one place — that is what makes it editable and debuggable,
nameandlabelon every field: we will connect the form to PHP in a few weeks and withoutnameno data would arrive,- a
valueon every option: PHP receives thevalue, not the text a person sees, - comments in the code: you can read and explain the code — that is what you will do at the defence,
- your project topic: everyone gets a different site.
When the result is not right, do not rewrite the whole prompt. Tell the AI what exactly to fix, for example: “The menu items are not side by side, fix the CSS.”
Úlohy na cvičenieLab tasks
Úlohy dostaneš aj ako zadanie cv02 v Classroom 50, sú v súbore README.md v tvojom repository.
Link na zadanie cv02: prijať zadanie
(platí pre skupiny B. Stehlíkovej; ostatné skupiny dostanú link od svojho cvičiaceho)
Úloha 3.1: Príprava Kubeflow a zadanie. Priprav si Kubeflow podľa návodu 04 Odovzdávanie, časť 1: v Explorer je hore WEB, dole na stavovej lište je Go Live. Ak tam nie je, rozšírenia vráti tento príkaz v termináli:
code-server --install-extension Natizyskunk.sftp --install-extension yandeu.five-server --install-extension bmewburn.vscode-intelephense-client --install-extension mblode.twig-language-2
Potom F1, Developer: Reload Window. Nastavenie pripojenia na sigma zostáva. Prijmi zadanie cv02 v Classroom 50 (link je vyššie) a repository naklonuj do ~/web/ti/cv02 podľa návodu 04, časti 2 a 3.
Úloha 3.2: Vygeneruj web. Prompt z Ukážky 4 vlož do AI a na koniec doplň tému svojho projektu. Výsledok ulož do ~/web/ti/cv02 presne v štruktúre z promptu. Do img pretiahni vlastný obrázok (image) a premenuj ho na photo.jpg. Stránky si pozri cez Five Server. Prečítaj komentáre v kóde — každý riadok musíš vedieť vysvetliť.
Úloha 3.3: Selectors. Jedným pravidlom v style.css zmeň farbu všetkých nadpisov (headings) h2 na oboch stránkach. Vytvor class .highlight (napr. farba pozadia alebo rámik) a použi ju aspoň na dvoch rôznych elements na dvoch rôznych stránkach. Element, ktorý má id, zmeň štýl cez #id selector.
Úloha 3.4: Box model. Sekciám (Sections) nastav vnútorný odstup (padding) a image rámik (border) s vonkajším odstupom (margin). V prehliadači cez F12 si na image pozri diagram box modelu a over, že hodnoty sedia.
Úloha 3.5: Pozicovanie. Pripni menu na vrch okna (position: fixed) a zariaď, aby neprekrývalo obsah (odsadenie obsahu zhora). V jednej section nastav rodiča ako position: relative a umiestni do jej rohu malý element (štítok alebo image) cez position: absolute.
Úloha 3.6: Form. Pridaj do form jedno nové field typu, ktorý tam ešte nie je — aj s label a name. Odošli form a v adresnom riadku nájdi svoje údaje.
Úloha 3.7: Oživenie. Položkám menu pridaj :hover a fields form :focus s viditeľnou zmenou (farba, rámik).
Úloha 3.8: Odovzdanie. Commit a push podľa návodu 04 Odovzdávanie, časť 5. Potom podľa časti 7 klikni pravým na priečinok cv02 a v menu úplne dole zvoľ Upload Folder. Na sigma tým doplníš aj pretiahnutý image: pri ukladaní v editore sa súbor nahráva sám, pretiahnutý image nie. Over v prehliadači https://sigma.tuke.sk/student/meno.priezvisko/ti/cv02/: obe stránky aj image.
Hodnotenie: 1 bod. V repository cv02 na GitHub aj na sigma je funkčný web: index.html, form.html, css/style.css, img/photo.jpg, a úlohy sú splnené. Commit a push najneskôr do nasledujúceho cvičenia.
You also get the tasks as the assignment cv02 in Classroom 50, in the README.md file in your repository.
Link to the assignment cv02: accept the assignment
(valid for B. Stehlíková’s groups; other groups get the link from their own teacher)
Task 3.1: Getting Kubeflow ready and the assignment. Get Kubeflow ready following guide 04 Submitting, part 1: Explorer shows WEB at the top, the status bar at the bottom shows Go Live. If it does not, this terminal command brings the extensions back:
code-server --install-extension Natizyskunk.sftp --install-extension yandeu.five-server --install-extension bmewburn.vscode-intelephense-client --install-extension mblode.twig-language-2
Then F1, Developer: Reload Window. The sigma connection settings stay. Accept the assignment cv02 in Classroom 50 (the link is above) and clone the repository into ~/web/ti/cv02 following guide 04, parts 2 and 3.
Task 3.2: Generate the web. Paste the prompt from Example 4 into an AI and add the topic of your project at the end. Save the result into ~/web/ti/cv02 exactly in the structure from the prompt. Drag your own image into img and rename it to photo.jpg. View the pages with Five Server. Read the comments in the code — you must be able to explain every line.
Task 3.3: Selectors. With one rule in style.css change the colour of all h2 headings on both pages. Create a class .highlight (e.g. background colour or a border) and use it on at least two different elements on two different pages. Change the style of the element that has an id via a #id selector.
Task 3.4: Box model. Give the sections inner spacing (padding) and the image a border with outer spacing (margin). In the browser, open F12, look at the box model diagram on the image and check that the values match.
Task 3.5: Positioning. Pin the menu to the top of the window (position: fixed) and make sure it does not cover the content (offset the content from the top). In one section set the parent to position: relative and place a small element (a label or an image) in its corner with position: absolute.
Task 3.6: The form. Add one new field of a type that is not in the form yet — with a label and a name. Submit the form and find your data in the address bar.
Task 3.7: Bring it to life. Add :hover to the menu items and :focus to the form fields with a visible change (colour, border).
Task 3.8: Submitting. Commit and push following guide 04 Submitting, part 5. Then, following part 7, right-click the cv02 folder and choose Upload Folder at the very bottom of the menu. This also gets the dragged image to sigma: a file saved in the editor is uploaded by itself, a dragged image is not. Check in the browser https://sigma.tuke.sk/student/name.surname/ti/cv02/: both pages and the image.
Grading: 1 point. The repository cv02 on GitHub and on sigma contains a working website: index.html, form.html, css/style.css, img/photo.jpg, and the tasks are done. Commit and push by the next lab at the latest.
Obhajoba a live codingDefence and live coding
Pri obhajobe budú použité iba otázky a úlohy z týchto zoznamov. Live coding robíš v kópii, odovzdaný stav v cv02 sa nezmení. Kópiu si priprav pred obhajobou:
cd ~/web/ti
mkdir -p obhajoba1
rsync -a --exclude .git cv02/ obhajoba1/cv02/
Potom klikni pravým na priečinok obhajoba1 a v menu úplne dole zvoľ Upload Folder. Kópia je na https://sigma.tuke.sk/student/meno.priezvisko/ti/obhajoba1/cv02/.
Vysvetli (code walkthrough)
- Ako je
style.csspripojený k stránke a prečo je v priečinkucss. - Prečítaj jedno pravidlo: čo je selector, čo property a čo hodnota.
- Aký je rozdiel medzi selector
h2,.highlighta#contact. - Čo vyberie selector
nav a. - Kedy použiješ class a kedy
id. - Aké vrstvy má box model. Ukáž ich na image v F12.
- Aký je rozdiel medzi padding a margin.
- Čo robí
position: fixedna tvojom menu. - Prečo má
bodyodsadenie zhora. - Ako spolu fungujú
position: relativeaposition: absolutev tvojej section. - Ako je obsah stránky vycentrovaný.
- Čo robia
:hovera:focus. - Čo hovorí
method="get". - Načo je attribute
namepri field. - Ako spolu súvisia
forvlabelaidfield. - Prečo majú všetky radio v skupine rovnaké
name. - Čo odíde z tvojho
selectpo odoslaní form. - Kde v adresnom riadku nájdeš údaje z form a ako sú zapísané.
- Ako v F12 zistíš, z ktorého súboru a riadka pravidlo je.
Uprav (live coding)
- Jedným pravidlom zmeň farbu všetkých headings
h2. - Pridaj class
.highlightďalšiemu element. - Vytvor novú class a použi ju na dvoch elements.
- Zmeň padding sections.
- Zmeň rámik image.
- Presuň štítok do iného rohu section.
- Zmeň vzhľad položky menu pri
:hover. - Zmeň vzhľad field form pri
:focus. - Pridaj do form field s
label,nameaid. - Pridaj do
selectjednu možnosť. - Zmeň šírku obsahu stránky.
Zdôvodni (design decisions)
- Prečo sú všetky štýly v jednom súbore a nie inline.
- Prečo vzhľad riešiš classes a
idsi nechávaš pre jedinečné elements. - Prečo má každé field
label. - Prečo má každé field
name. - Prečo je menu pripnuté na vrchu okna a čo by sa stalo bez odsadenia obsahu.
Definition of Done
- Repository cv02 je na GitHub:
index.html,form.html,css/style.css,img/photo.jpg. - Web je na sigma: obe stránky aj image.
- V HTML nie sú inline štýly ani tag
<style>. - Form sa dá odoslať a údaje sú v adresnom riadku.
- Každé pravidlo vo svojom
style.cssvieš prečítať.
Only the questions and tasks from these lists are used at the defence. You do the live coding in a copy; the submitted state in cv02 does not change. Prepare the copy before the defence:
cd ~/web/ti
mkdir -p obhajoba1
rsync -a --exclude .git cv02/ obhajoba1/cv02/
Then right-click the obhajoba1 folder and choose Upload Folder at the very bottom of the menu. The copy is at https://sigma.tuke.sk/student/name.surname/ti/obhajoba1/cv02/.
Explain (code walkthrough)
- How
style.cssis attached to the page and why it is in thecssfolder. - Read one rule: which part is the selector, the property and the value.
- The difference between the selectors
h2,.highlightand#contact. - What the selector
nav aselects. - When you use a class and when an
id. - Which layers the box model has. Show them on the image in F12.
- The difference between padding and margin.
- What
position: fixeddoes on your menu. - Why
bodyhas top padding. - How
position: relativeandposition: absolutework together in your section. - How the page content is centred.
- What
:hoverand:focusdo. - What
method="get"says. - What the
nameattribute of a field is for. - How
forin alabeland theidof a field are related. - Why all radios in a group share one
name. - What your
selectsends after the form is submitted. - Where in the address bar you find the form data and how it is written.
- How you find out in F12 which file and line a rule comes from.
Modify (live coding)
- With one rule change the colour of all
h2headings. - Add the
.highlightclass to another element. - Create a new class and use it on two elements.
- Change the padding of the sections.
- Change the border of the image.
- Move the label to another corner of the section.
- Change the look of a menu item on
:hover. - Change the look of a form field on
:focus. - Add a field with a
label, anameand anidto the form. - Add one option to the
select. - Change the width of the page content.
Justify (design decisions)
- Why all styles are in one file and not inline.
- Why you style with classes and keep
idfor unique elements. - Why every field has a
label. - Why every field has a
name. - Why the menu is pinned to the top of the window and what would happen without offsetting the content.
Definition of Done
- The repository cv02 is on GitHub:
index.html,form.html,css/style.css,img/photo.jpg. - The website is on sigma: both pages and the image.
- There are no inline styles and no
<style>tag in the HTML. - The form can be submitted and the data is in the address bar.
- You can read every rule in your
style.css.