Cov txheej txheem:

Tsim Koj Tus Kheej Lub Vev Xaib rau Pib: 5 Kauj Ruam
Tsim Koj Tus Kheej Lub Vev Xaib rau Pib: 5 Kauj Ruam

Video: Tsim Koj Tus Kheej Lub Vev Xaib rau Pib: 5 Kauj Ruam

Video: Tsim Koj Tus Kheej Lub Vev Xaib rau Pib: 5 Kauj Ruam
Video: yuav tau tsim kho tus kheej lub neej thiaj yuav vam meej tau 2024, Hlis ntuj nqeg
Anonim
Tsim Koj Tus Kheej Lub Vev Xaib rau Pib
Tsim Koj Tus Kheej Lub Vev Xaib rau Pib

Txawm hais tias koj puas tau npau suav xav ua lub khoos phis tawj programmer lossis puas tau siv lub vev xaib, uas cia peb ntsib nws, yuav luag txhua tus ntawm peb, cov ntaub ntawv thev naus laus zis tau dhau los ua tus txha caj qaum ntawm kev lag luam. Txawm hais tias qhov kev zov me nyuam yuav zoo li me ntsis txaus ntshai thaum xub thawj, kuv lub hom phiaj yog qhia koj cov hauv paus hauv paus ntawm kev tsim web yog li tom qab qhov kev qhia no, koj yuav muaj peev xwm ua koj tus kheej lub vev xaib. Nrog qhov ntawd ntawm txoj kev, cia peb mus rau nws!

Khoom siv

  • Lub Macintosh lossis Windows PC (txawm hais tias Linux kev cuam tshuam kuj tseem tuaj yeem siv tau, Kuv tab tom hla lawv tam sim no vim qhov no yog qhov pib qhia).
  • Koj xaiv cov ntawv sau (Notepad ntawm Windows, TextEdit ntawm Mac) lossis koj xaiv IDE. Hauv kuv qhov kev paub, Kuv tau pom Visual Studio Code ua haujlwm zoo tshaj plaws rau kuv tus kheej yog li kuv kuj tseem xav kom txheeb xyuas nws ntawm no: https://code.visualstudio.com/ tsis hais nws ua haujlwm ntawm txhua lub platform OS.

Kauj Ruam 1: Cim npe thiab Me ntsis Keeb Kwm

Tags thiab Me ntsis Keeb Kwm
Tags thiab Me ntsis Keeb Kwm

Thaum koj tau txiav txim siab koj qhov kev xaiv tus ntawv sau lossis IDE, cia pib nrog qhov pib.

Ntseeg nws lossis tsis ntseeg, HTML lossis HyperText Markup Language tau nyob ib puag ncig ze li 30 xyoo tam sim no thiab nrog txhua xyoo tau los ntau dua thiab txhim kho cov lus. Tam sim no, koj yuav tau nug, tus browser txhais li cas muab tso rau ntawm qhov screen? Qhov no tau ua tiav hauv ob peb ntu:

HTML cov ntaub ntawv formatting yog yooj yim. Koj muaj ob ntu hu ua lub taub hau thiab lub cev. Lub taub hau ntawm lub vev xaib muaj cov cai uas tsis pom rau tus neeg siv. Qhov no yog siv los txuas cov ntawv txheeb thiab tshaj tawm lwm cov khoom tsim nyog xav tau rau lub xaib kom pom tseeb. Ua raws lub taub hau, lub cev zoo li nws lub suab, lub cev ntawm lub vev xaib. Nov yog qhov uas koj tau hais koj lub suab thiab qhia rau cov neeg saib pom koj cov txuj ci HTML zoo heev! Tam sim no nws tsis yooj yim li tsuas yog ntaus cov ntawv rau hauv lub cev thiab ua kom nws pom raws nraim qhov koj xav tau, tab sis nws yuav luag yooj yim hauv qhov kev nkag siab nrog kev siv qee yam peb hu ua cim npe.

Nov yog qee qhov pib HTML cim npe:

  • title - uas yog siv los qhia rau tus browser lub npe ntawm nplooj ntawv yog dab tsi. Qhov no kuj yog qhov koj pom thaum koj saib ntawm lub vev xaib.
  • h1, h2, h3, h4 - uas tau siv rau ntau qhov sib txawv ntawm lub hauv paus nrog h1 yog qhov loj tshaj thiab h4 yog qhov tsawg tshaj plaws. Kuv yuav npog ntau ntxiv txog qhov no hauv ntu tom ntej.
  • p - kab lus, siv rau kev sau kab lus ntawm cov ntawv. Zoo li kab lus ntawm daim ntawv.
  • br - so, uas ntxig rau kev so hauv kab nrog cov ntawv.
  • a - siv rau kev tsim txuas mus rau lwm nplooj ntawv, zoo li nyem qhov txuas.
  • img - siv los txuas cov duab rau lub vev xaib.
  • ul, ol, li - cov npe tsis tau teev tseg, cov npe xaj khoom, thiab cov npe khoom.
  • - siv los ua cov lus pom hauv kab lus uas yuav tsis pom los ntawm tus neeg siv kawg.

Thiab ntawm no yog qee cov cim npe CSS (pom):

  • xim - siv los muab cov xim tshwj xeeb rau cov khoom tshwj xeeb lossis teeb tsa ntawm lub vev xaib.
  • font-size-siv los hloov font loj ntawm nplooj ntawv.
  • xim tom qab-siv los hloov xim keeb kwm yav dhau ntawm qee yam lossis tag nrho nplooj ntawv.

Kuv kuj tau txuas daim ntawv me me dag los pab koj yog tias koj xav tias ploj me ntsis, tab sis tsis txhob txhawj, koj yuav raug dai ntawm lub sijhawm! Ib qho ntxiv, www.w3schools.com kuj tseem yog cov peev txheej zoo rau ib qho ntawm koj cov lus nug txog kev ua haujlwm. Lawv yeej tau cawm kuv lub sijhawm lossis ib yam nkaus.

Qhov tseem ceeb li cas qhov browser nyeem cov ntawv yog yooj yim. Nws mus ib kab los ntawm kab thiab txheej txheem ua haujlwm los ntawm kev ua haujlwm. Cov cim tau siv los tshaj tawm cov cim xws li

thiab tau siv los kaw cov cim xws li

. Qhov no yog qhov tseem ceeb txwv tsis pub lub browser tsis nyob qhov twg kom nres. Hauv nruab nrab ntawm

thiab

cim npe, yog qhov uas koj nkag mus rau yam koj xav tau!

Kauj ruam 2: Editor Teeb

Teeb tsa Editor
Teeb tsa Editor
Teeb tsa Editor
Teeb tsa Editor
Teeb tsa Editor
Teeb tsa Editor

Tam sim no peb tau hais me ntsis txog cov hauv paus ntsiab lus ntawm HTML lub vev xaib, cia peb dhia dej thiab sim nws rau peb tus kheej. Rau cov kauj ruam tom ntej no kuv yuav siv Visual Studio Code los teeb tsa lub vev xaib, tab sis cov txheej txheem ntawm cov cai yuav zoo ib yam yog tias koj nyiam dua nrog tsuas yog siv Notepad lossis TextEdit.

Hauv Notepad:

  • Nrog Notepad, txoj haujlwm pib nrog daim ntawv dawb uas ua rau nws yooj yim heev rau pib. Qhov no tseem yuav tso cai rau peb dhia ob peb kauj ruam piv rau siv VS Code. Cia peb pib los ntawm kev khaws cov ntawv hauv qhov raug.
  • Nyem Cov Ntaub Ntawv> Txuag
  • Nkag mus rau hauv lub npe rau koj cov ntawv ua raws los ntawm.html thiab hauv qab Txuag raws li hom, xaiv txhua cov ntaub ntawv. Nyem tseg.

Tsis pub dhau VS Code:

  • Txoj hauv kev zoo tshaj rau koj kom tau txais txiaj ntsig ntawm txhua yam ntawm IDE cov yam ntxwv yog pib los ntawm kev tsim cov ntawv thiab qhia rau IDE seb hom ntaub ntawv nws yog dab tsi. Qhov no tuaj yeem ua tau raws li hauv qab no:
  • Nyem Cov Ntaub Ntawv> Cov Ntaub Ntawv Tshiab
  • Cov ntaub ntawv khoob qhib
  • Tom ntej no, koj yuav xav pib los ntawm kev khaws cov ntaub ntawv, txawm tias tsis muaj dab tsi, vim qhov no yuav tso cai rau IDE tuaj yeem nkag siab tias hom ntaub ntawv twg cov khoom kawg yuav yog. Thaum txuag nco ntsoov suav nrog.html txuas ntxiv ntawm qhov kawg ntawm cov npe ntawv. Nyem tseg.

Kauj Ruam 3: Daim phiaj xwm

Hneev taw
Hneev taw
Hneev taw
Hneev taw

Tom qab koj tau ua tiav kev txuag koj cov npe filename.html, cia pib los ntawm kev tsim lub moj khaum rau peb lub vev xaib. Nco ntsoov los saum toj saud qhov tseem ceeb ntawm cov ntawv peb yuav tsum tshaj tawm ua ntej peb tuaj yeem pib nrog tsim seem ntawm nplooj ntawv HTML. Pro-tip: thaum pib lub moj khaum rau lub xaib, lub! DOCTYPE HTML lossis qhia rau tus browser tias cov ntawv nws nyeem yog cov ntaub ntawv html. Qhov no tuaj yeem ua haujlwm tau yog tias koj muaj hom sib txawv ntawm cov lej hauv tib cov ntaub ntawv thiab xav hloov ntawm cov neeg txhais lus. Txog qhov nthuav dav ntawm cov lus qhia no, peb yuav tsis kov ntau dhau ntawm qhov no tab sis yog tias tom qab Cov Lus Qhia no koj xav paub txhawm rau txheeb xyuas ntau ntxiv txog kev txhim kho HTML, xav tias yuav muab tshuaj rau nws. Kuv yuav ntxig rau! DOCTYPE HTML tag nyob rau sab saum toj ntawm cov ntawv rau kev xyaum zoo tshaj plaws. Nco ntsoov qhib thiab kaw nrog.

Nov yog qhov twg khaws cov ntaub ntawv ua ntej koj pib ua haujlwm los ua ke, tam sim no IDE paub tias nws ua haujlwm nrog HTML cov ntaub ntawv, nws yuav siv kev nkag siab kom ua tiav qhov kev hais tawm thiab muab cov lus qhia kom koj tsis txhob yuam kev hnov qab kaw tag. Nco ntsoov tias rau koj ntawm cov uas siv Notepad, kev nkag siab tsis muaj nyob zoo li hauv IDE. Peb pib los ntawm kev nkag mus rau lub taub hau thiab lub cev cim npe raws li hauv qab no: (saib duab thib ob).

Tam sim no cov ntaub ntawv teeb tsa tau ua tiav, peb tuaj yeem tawm mus rau kev sib tw thiab muaj kev lom zem!

Kauj ruam 4: Code; Code; Code;

Code; Code; Code
Code; Code; Code
Code; Code; Code
Code; Code; Code
Code; Code; Code
Code; Code; Code
Code; Code; Code
Code; Code; Code

Peb tuaj yeem pib los ntawm kev ntxig lub npe rau peb cov ntaub ntawv tsim tshiab. Sau dab tsi koj xav tau. Nco ntsoov tias qhov no yog lub npe uas tshwm hauv qhov browser tab. Cia peb tseem pib los ntawm kev nkag mus rau nqe lus rau peb lub xaib. Rov qab los ntawm ua ntej seb peb ua qhov no li cas. Kuv puas tau hnov h1/2/3/4? Yog qhov tseeb!

Ua ntej peb mus txuas ntxiv, Kuv pom nws muaj txiaj ntsig los qhib peb cov ntaub ntawv hauv qhov browser browser kom peb tuaj yeem pom hauv lub sijhawm tiag tiag li cas peb cov kev hloov pauv cuam tshuam hauv qhov browser. Koj tuaj yeem ua qhov no los ntawm nyem File> Save to save the file, navigating to the folder in which the HTML file is saved, for me this is the desktop, and use the browser of your choice to open the file and would you look at that, muaj koj lub vev xaib! Nco tseg: Kuv tus kheej siv Safari ua kuv qhov browser xaiv ntawm kuv lub khoos phis tawj, txawm li cas los xij, hauv kev txhim kho lub vev xaib, Firefox yog tus qauv txheem kub rau kev ntsuas raws li nws ua haujlwm nrog yuav luag txhua lub vev xaib sau lus.

Raws li koj tuaj yeem pom, lub npe tau qhia ntawm lub tab, nrog rau pom peb h1 nqe lus. Kuv nyiam kom muaj ob lub browser qhov rai ntawm cov ntaub ntawv qhib ib sab ntawm IDE zoo li thaum koj hloov pauv hauv IDE thiab txuag, cov kev hloov pauv sai sai hauv qhov browser.

Xav tias dawb sim ntxiv cov cim npe thiab ua si ib ncig nrog qhov sib txawv uas koj tuaj yeem ua nrog HTML. Raws li koj tuaj yeem pom hauv qab no, Kuv tau ntxiv ob peb nqe lus, so, sab nraud txuas mus rau Instructables.com, duab, (uas tuaj yeem txuas nrog los ntawm lwm qhov chaw lossis hauv tib phau ntawv teev npe qhov twg. HTML cov ntaub ntawv khaws cia), ib qho piv txwv ntawm daim ntawv teev npe tsis tau teev tseg, daim ntawv xaj xaj, thiab qhov kawg tawm tswv yim.

Yog tias koj xav sim ntxiv qee qhov xim, thiab xaiv cov kev xaiv, koj tuaj yeem nkag mus rau cov cim cim nyob hauv lub taub hau ntawm cov ntawv. Nov yog lub ntsiab lus uas qhov no hloov pauv los ntawm HTML rau CSS tab sis rau kev pom pom, Kuv yuav nkag mus rau ob peb kab kom koj tuaj yeem pom qhov no ua haujlwm li cas. Qhov tseem ceeb li cas CSS ua haujlwm yog nws tso cai rau koj los tswj cov ntsiab lus HTML hauv kev ua haujlwm los ntawm kev siv cov kab zauv {} txhawm rau nkag mus rau koj cov lej rau hauv cov ntsiab lus tshwj xeeb HTML.

Kauj Ruam 5: Kev Xav Thaum Kawg

Kev Xav Thaum Kawg
Kev Xav Thaum Kawg

Thiab koj muaj nws; koj tau ua tiav tsim koj thawj lub vev xaib! Vim tias qhov no yog tus pib phau ntawv qhia, Kuv xav ua koj thawj qhov kev paub nrog HTML qhov kev lom zem. Txoj hauv kev zoo tshaj plaws los kawm hauv kuv qhov kev paub yog dhia dej thiab sim ua haujlwm ntawm tes, saib koj tuaj yeem ua dab tsi nrog koj tus lej thiab tseem pom yuav ua li cas koj tuaj yeem ua txhaum koj li chaws. Qhov no tsim kev ncaj ncees thiab pab koj kom nkag siab zoo li cas thiab vim li cas txoj cai ua haujlwm zoo li nws ua. Nco ntsoov tias www. W3Schools.com yog cov peev txheej zoo rau cov lus nug thiab lawv txawm muab lub sandbox virtual hauv qhov browser los sim koj cov cai. Vam tias koj tau kawm qee yam thiab zoo siab coding!

Pom zoo: