How to Code a Website (Using HTML & CSS) | websitesetup.org

文章推薦指數: 80 %
投票人數:10人

How to Code a Website · Learn the basics of HTML · Understand HTML document structure · Get to know CSS selectors · Put a CSS stylesheet together ... KarolKrolStaffWriterTwitterFacebookLastupdated:Dec28,20208Comments WanttolearnhowtocreateawebsitewithHTMLandCSS?You’reintherightplace.Inthisguide,weshowyouallthestepstogetfromablankscreentoaworkingwebsitethat’soptimizedandquitegood-lookingatthesametime.Butfirst,whatisHTMLandCSS?Well,youcouldjustlookupbothtermsinWikipedia,butthosedefinitionsaren’tveryreader-friendly.Let’ssimplifythingsabit:HTML(HypertextMarkupLanguage)definesthestructureandcontentsofawebpage–wherethingsgo,howtheyarelaidout,andwhat’sonthepageCSS(CascadingStyleSheets)definesthestyling/presentationofawebpageandtheelementsonitYoucan’treallyhaveonewithouttheother–thetwoworktogethertomakeupthefinalwebpage,itsdesign,andthecontentthat’sonit.Note;whenwesay“awebpage,”whatwemeanisasingleHTMLdocument–asinglepagethat’spartofyourwebsite.Whereas,“awebsite”isthecompletething–yourwholesitewithallitsindividualwebpages.TableofcontentsLearnthebasicsofHTMLUnderstandHTMLdocumentstructureGettoknowCSSselectorsPutaCSSstylesheettogetherGetBootstrapPickadesignCustomizeyourwebsitewithHTMLandCSSAddcontentandimagesFine-tunecolorsandfontsCreateadditionalpagesIfyouthinkthisistoocomplicated,werecommendeithercreatingawebsiteusingWordPressorchoosingoneofthewebsitebuilders.BeforeYouStart,GatherYourResources:So,thefirstthingyouneedevenbeforecreatingawebsitewithHTMLandCSSisawebserver(hosting).Don’tworry,though;youdon’thavetobuyyourownmachine.Manywebhostingcompanieswillsellyouasimplehostingserviceontheirmachines.Justgooglefor“webhosting”andpicksomethingthatisn’ttooexpensiveorcheckourwebhostingreviews.Withtheserversorted,thenextthingyouneedisadomainname.Thedomainnameiswhatthewebsiteisidentifiedontheweb.Forexample,thissite’sdomainnameiswebsitesetup.org.Whenyouhavebothadomainnameandaserver,youcanconnectthetwotogether.Tohavethissortedoutwithnopainonyourend,werecommendsigningupwithacompanylikeBluehost.Theywillhandleallthesetupforyou.Meaningthattheywill:(a)setupahostingaccountforyou,(b)registeradomainnameonyourbehalf,(c)configureeverythingtoworktogether,and(d)giveyouaccesstoaneasy-to-usedashboard.Goaheadandsignupwithanyofthewebhostingservices, we’llwait.Whenyou’rebackandhaveyourwebserverconfiguredandreadytogo,scrolltothenextstep.P.S.IfyoujustwanttoexperimentwithanHTMLwebsiteonyourcomputer,anddon’tintendtomakeitpublic,usealocalwebserversoftware.TheonewerecommendandliketouseiscalledXAMPP.IthasversionsforbothMacandPC,andit’seasytouse.Here’saguideonhowtoinstallitonyourcomputer.1.LearntheBasicsofHTMLIfyouareanewtoHTML,youmayfindthisHTMLforBeginners(UltimateGuide)useful.ThemainelementofanHTMLstructureisanHTMLtag.Atag,forexample,lookslikethis:SOMETHINGHere,we’redealingwithatag.Thisonewillboldapieceoftextthat’sbetweentheopeningtag()andtheclosingtag().Inthiscase,thatpieceoftextisSOMETHING.Butthereareothertags,justtonameafew:...willitalicizethetextbetweentheopeningandclosingtags...willunderlineit

...

isaparagraphoftext

...

isthemainheaderonthepageApartfromthosesimpletags,therearealsomorecomplextags.Forexample,ifyouwanttobuildalistlikethefollowing:Item1Item2Item3…youcandothatwiththefollowingHTMLcode:
  • Item1
  • Item2
  • Item3
Or,ifyouwanttoaddalinktoanotherpage,likethisone:Thisisalinktoourhomepage…youcandothatwiththispieceofcode:ThisisalinktomyhomepageReadthistogetthefulllistofHTMLtags.It’llbecomeusefulasyou’recreatingawebsitewithHTMLandCSS.2.UnderstandHTMLDocumentStructureThinkofyourHTMLpageasifitwasbuiltofLegos.Youputdifferentbricksontopofoneanothertoendupwithagivenbiggerstructure.ButinsteadofLegobricks,yougetHTMLtags…Here’sthesimplestHTMLdocumentstructure: Hello,world!

Hello,world!

Myfirstwebpage.

Youcantakethecodeabove,copyandpasteittoanewfile,savethedocumentasindex.html,andit’sgoingtobeaperfectlyvalidHTMLpage.Let’sexplaintheindividualpartsofthiscode:–theinitialdeclarationofthedocument–anotherdeclaration;saysthatwhat’stocomenextisanHTMLdocumentwritteninEnglish–marksthestartoftheheadsection;theheadsectioniswhereallthebasicparametersofthepagego;mostofthosearenotgoingtobeshownonthescreen;theyjustdefinewhat’sgoingonunderthehood–defineswhatcharactersetisusedtowritethedocument;noneedtospendtoomuchtimeonthis;justusethisdeclarationasisHello,world!–thetitleofthepage;thisiswhatpeoplewillseeinthetitlebaroftheirbrowsers,e.g.:–marksthestartofthebodysection;thisiswhereallthecontentofthepagegoes;it’sthemainpartofanHTMLdocument;letusemphasizethis,thissectioniswhereyou’regoingtobeincludingallthecontentthat’smeanttoappearonthepage

Hello,world!

–themainheaderonthepage

Myfirstwebpage.

–asimpleparagraphoftext–theclosingtagofthewholeHTMLdocumentAnimportantnotehere.WorkingonanHTMLfileinabasictextapporacomplextextprocessorlikeMSWordisnotagoodexperience.Tomakethingseasyonyourself,installaHTMLeditorcalledSublimeText.IthasversionsforbothMacandPC,anditisfree.Whyisitbetter?Amongotherthings,itwillcolorizethesyntaxofanHTMLfile.Meaning,it’llvisuallydistinguishyourHTMLtagsfromtextcontent,tagparameters,andothervalues.Basically,it’llallbecomereadable.Here’swhatoursimpleHTMLstructurelookslikeinSublimeText:Okay,backontopic.Youcantakethatnewindex.htmlfileofyours,copyittowherethemaindirectoryofyourwebserveris,andthenseethatpagebynavigatingtoitthroughawebbrowser.Don’tgettooexcited,though;thispagewillberatherugly(seebelow).Okay,sothepageisugly,howtomakeitnotso?3.GettoKnowCSSSelectorsJustlikeHTMLhasitstags,CSShasselectors.Selectorsdescribehowagivenelementshouldbehaveappearance-wise. Here’sanexampleofaCSSselector:p{ font-size:18px; } ThisselectorindicatesthatallHTML

tagswithinthedocumentwillhaveafontsizeof18px.However,amorepracticalwayofusingCSSselectorsisnottorestrictalltagsofagiventypetoacertainstyling,butrathercreatedifferent“classes”andassignthemtotagsonebyone.Forexample,aclassselectorinCSSlookslikethis:.normal-text{ font-size:18px; } Noticethedot(.)beforethenameoftheclass(normal-text).Withthe“normal-text”classdefined,wecannowassignthatclasstothosespecificHTMLtagsthatwewanttomake18pxinsize.Forexample:Thistextisgoingtobe18px.

Let’stakeonemoreminutetoexplainalltheelementsofthatpieceofCSScodeabove:.normal-text–classdefinition;everythingafterthenameoftheclassandbetweentheopeningandclosingbrackets{}defineswhattheelementsassignedtothisclasswilllooklikefont-size–anexampleCSSproperty18px–avalueassignedtothepropertyThere’satonofCSSpropertiesapartfromtheabovefont-size.Here’sthecompletelistifyou’recurious.4.PutTogetheraCSSStylesheetAnHTMLdocumentisverystructural–everyelementhasitsplace,andtheorderofelementsiscrucialforthefinalconstructionandappearanceofthewebpageinquestion.ACSSdocumentisalotlessso.CSSdocumentsareoftenreferredtoasstylesheets.Basically,aCSSstylesheetisalistofalltheclassdefinitionsthatarebeingusedinthecorrespondingHTMLdocument.Theorderoftheclassdefinitionsisnotthatcrucialmostofthetime(atleastforsimpledesigns).ThewayyouputaCSSstylesheettogetherisbydefiningeachclassonebyone,andthentestingiftheoutcomeinyourpagedesigniswhatyouwanted.Thissoundsliketediouswork,anditis.Butwe’llmakethingseasieronyou,andnotforceyoutolearnHTMLandCSSdesignbyhand.Insteadofteachingyoueverythingfromscratch,we’lltakealivingorganismanddissectitselements.ThisiswhereathingcalledBootstrapcomesintoplay.5.Download/InstallBootstrapBootstrapisanopen-sourcetoolkitforcreatingawebsitewithHTMLandCSS.InplainEnglish,BootstraptakescareofthebasicstructureofanHTMLdocumentandCSSstylesheetforyou.Itdeliversaframeworkthatmakessurethatthemainscaffoldingofyourwebpageisreadyandoptimizedforfurtherdevelopment.Basically,Bootstrapletsyounotstartfromscratch,andinsteadgorightintothefunpart.Withit,youdon’thavetoworkontheoftenboringearlystagesofcreatingawebsitewithHTMLandCSS.Therearetwopathsyoucantake:Option(a):learnBootstrap–gototheBootstraphomepage,downloadthemainBootstrappackageandstartbuildingontopofit.Option(b):takeashortcut–getastarterpackforBootstrapwithagood-lookingdesignandademowebpagealreadybuilt.Option(a)mighthavesomelearningcurveatthebeginning,butit’snotinanywaytheworsewaytoapproachcreatingawebsitewithHTMLandCSS.OnceyoumasterthecoreBootstrapstructure,itmightbeeasierforyoutobuildnewpagesandmakethemlookexactlyasyouwantthem.TheBootstrapdocumentationisagreatplacetogetstartedwiththispath.We’regoingtogowithOption(b)forthisguide.We’redoingthisforacoupleofreasons,chiefofthem:Startingwithaready-madestructuresavesalotofpainintryingtofigureoutthebasicnecessitiesofanHTMLdocument.Thisletsyoufocusontheinterestingstuff–likelayingoutcontentandmakingitlookgood.Inshort,learningthingsthiswaywillgiveyouabetter-lookingresultquicker,whichweguessiswhatyouwant.6.PickaDesignWhenyou’recreatingawebsitewithHTMLandCSS,youarefreetouseanyBootstraptemplateyoulike.Theyshouldallworksimilarlyenough.However,forthisguide,we’regoingtouseoneofthetemplatesbyStartBootstrap.Theyhaveaniceselectionoffreetemplatesthatareoptimized,worktrouble-free,andarealsoverywelldesigned.Thethemewe’regoingtouseiscalledCreative.Thefinaleffectwe’regoingforwilllooksomethinglikethis:Tobeginwith,theCreativetemplate,clickontheFreeDownloadbuttonthat’sontheright(onthispage)andsavethezippackagetoyourdesktop.Unzipthepackageandmoveitscontentstothemaindirectoryofyourlocalwebserveroryourwebhostingaccount.Nowopenthatlocationthroughyourwebbrowser.You’llseethestockversionofthetemplate:It’salreadyquitegood-looking,butnowit’stimetolearnhowtouseHTMLandCSStomakeitintoexactlywhatyouwantittobe.7.CustomizeYourWebsiteWithHTMLandCSSLet’sworkonthehomepageofthedesignfirst.Thisisgoingtoshowushowtoreplacethegraphics,texts,andtuneeverythingupingeneral.We’vetalkedabouttheheadsectionofanHTMLdocumentbrieflyabove.Let’shaveamorein-depthlookintoithere.Whenyouopentheindex.htmlfileofyourBootstrapsiteinSublimeText,you’llseeaheadsectionlikethis(weremovedallthenon-crucialthingsfromthiscodeforclarity*): Creative-StartBootstrapTheme *Apartfromtheabove,therewasalsocodetoloadGoogleFonts,FontAwesomeiconsandalightboxmodulefortheimagesdisplayedonthepage.Mostofthedeclarationsherewealreadyknow,butthereareacoupleofnewones:Firstoff,everythingbetweenthebracketsisanHTMLcomment.Itdoesn’tshowuponthefinalpage.–it’soneofBootstrap’sowndeclarationtags.Itdefinesthesizeofthewebsite’sviewport.–thislineloadstheCSSstylesheetoftheCreativetemplateanditalsohousesthedefaultstylesheetofBootstrap.Let’smodifythatlastdeclaration–thelineloadingtheCSS–tomakeiteasiertoworkwithlateron.Changethatlineto: Thisisjustasmalldifference–it’llloadthenon-shortenedversionofthesameCSSsheet.Thisversionisjusteasiertomodify.Nowscrolldowntotheverybottomoftheindex.htmlfile.You’llseethefollowinglinesrightbeforetheclosingbodytag: They’reresponsibleforloadingJavaScript filesthathandlesomeofthemorevisualinteractionsofthedesign.Forinstance,whenyouclickontheAboutlinkinthetopmenu,you’llbetakensmoothlytotheaboutblockonthesamepage–this,amongotherthings,isdoneviaJavaScript.Wedon’tneedtotroubleourselvesunderstandingthiscoderightnow.Let’sleavethisforanothertime.Instead,let’sworkonaddingourowncontenttothepage:8.AddContentandImagesThefirstthingyou’llwanttodoischangethetitleofthepage.1.ChangetheTitleFindthetitletagintheheadsectionandreplacethetextbetweenthetagstosomethingofyourown:MyHTMLSite2.CustomizetheHeroSectionTheherosectioniswhatwecallthisblock:Itwouldbecooltohaveourowncontentinsideofit.Tomodifythisblock,gobacktoyourindex.htmlfileandfindthissection: ... ... FindOutMore Thiswholeblockofcodecontrolswhat’sintheherosection.Therearesomenewtagshere:
–thisisatagdefiningthatthiswholesectionistheheaderofthepage;thistaghasacoupleofbrothersandsistersintheformofthe
tagand
tag
–isageneralCSStagthatindicatesthatwhatfollowsisaseparatesection(akadivision)intheHTMLdocument;usingitmakesiteasiertodistinguishindividualsectionsonthepagevisuallyYou’llalsonoticethatsomeoftheothertags(whichwealreadyknow)looktobeabitmorecomplex,withmultipleCSSclassesassignedtothem.Forexample:... Theclassesassignedtothe

taghereistext-uppercasetext-whitefont-weight-bold.TheseclasseshavebeencreatedbyBootstrapandbytheCreativetheme’sdeveloper.ThegoodnewsisthatyoutoocanusethemfreelywhencreatingawebsitewithHTMLandCSS.Quitefrankly,youcancustomizeanytagyouaddtoyourpage’sstructurebyassigninganynumberofclassestoit.Ifyouwanttoseethecompletelistoftheclassesavailable,youcanopenthemaincreative.cssfilethat’sinthecsssubdirectoryoftheCreativetheme.Gettingagraspofalltheseclassescanseemintimidatingatfirst,butit’sactuallywayeasierthanitlooks.Forexample,oneoftheclassesassignedtosomeoftheparagraphsinourindex.htmlfileisfont-weight-light.Whenyoujumpintothecreative.cssfileandctrl+flookingforthatclassname,you’llseethatitsimplysetsthefont-weightparameterlikeso:.font-weight-light{ font-weight:300; } Modifyingthedefaulttextsintheindex.htmlfileisverysimple.Justfindthetagthatyouwanttoeditandchangewhat’sbetweentheopeningandclosingtags.Forexample,tochangethemainheadline,justchangethis:YourFavorite...

Tosomethinglikethefollowing:AdmiremyHTMLwebsite! Youcandothesametoalltheparagraphsandothertagsonthepage.What’simportantisthatyoucanalsoaddnewparagraphsfreely.Forexample,wecantaketheparagraphthat’salreadyonthepage,makeacopyofitandpasteitrightbelowtheoriginalparagraph;likeso:StartBootstrapcan... Paragraph2 Now,withthetextstakencareof,let’sreplacetheimagethat’sinthebackground.ThisisabitmorecomplicatedtodosinceitrequiresustogointotheCSSstylesheetfileanddothemodificationthere.AsyoucanseeintheHTMLcodeoftheMastheadsection,notagwouldindicateincludinganimagetothepageinanyway.ThisisalldoneviaCSS.WhenyoutakeanotherlookatthewholeblockofcodehandlingtheMastheadsection,you’llseethatit’sassignedtoaclasscalledmasthead.Thislineofcodehandlestheclassassignment: Themastheadclassistheonethatputsanimageinthebackgroundofthewholeblock.Let’sopenthecreative.cssfileagainandlookforthe“masthead”class:header.masthead{ padding-top:10rem; padding-bottom:calc(10rem-72px); background:linear-gradient(tobottom,rgba(92,77,66,0.8)0%,rgba(92,77,66,0.8)100%),url("../img/bg-masthead.jpg"); background-position:center; background-repeat:no-repeat; background-attachment:scroll; background-size:cover; } Thiscodedoesallkindsoffancythingstoourimage(likeaddinganoverlay,shading,etc.),buttheimportantpartisthis:url("../img/bg-masthead.jpg").Thisisthelinethatindicateswheretofindthebackgroundimage.It’sgoingtobeintheimgsubdirectory.Tochangethisbackgroundimage,takeanyimageofyourown,copyittotheimgsubdirectoryandthencopyandpasteitsnameinplaceoftheoriginalbg-masthead.jpgfile.Inshort,changethis:url("../img/bg-masthead.jpg")tothis:url("../img/YOURFILE.jpg").3.CustomizetheOtherBlocksonthePageAsyougothroughtheindex.htmlfile,you’llnoticethatthere’salotofdifferentsectionsalreadyonthepage.Wehaveasectionforthenavigation,andaboutablock,someservices,aportfolio,acalltoaction,acontactblock,andafooter.Whilethere’sdifferentcontentinallthesesections,thesectionsthemselvesaresimilarinstructure.TheyallhaveroughlythesamesetofHTMLtags–justdifferentCSSclassesassignedtothem.Thebestwaytomodifythepagetofityourneedsistogothroughtheblocksonebyoneandexperimentbychangingthingsaround.Apartfrommodifyingthetexts,youcanalsomovewholesectionsaround(thepartsbetweenthe
tags).Granted,youdohavetodothatbyhand(bycuttingandthenpastingelementsintoplace),itstillisstraightforwardtodo.Withthatbeingsaid,therearetwoquitebasicmodificationsthatwehaven’ttalkedaboutyet.Let’scoverthesenext:9.Fine-TuneColorsandFontsChangingcolorsorfontsisveryeasytodoinHTMLandCSS.Thesimplestthingyoucandoisassignsomein-linestylingtoanHTMLtag.Forexample:Redtext InHTML,colorsarerepresentedbytheirhexvalues;“#FF0000”isred.Here’satableofalltheotherstandardcolors.AbetterwaytoassigncolorsistodoitviatheCSSstylesheet.Forexample,togetthesameeffectasthecodeabove,wecouldputthisinourCSSstylesheet:p.red{ color:#FF0000; } AndthenusethefollowingpieceofHTMLcodeinthemaindocument:Redtext ThatsecondmethodisbasicallyhowthingsaredoneinBootstrap.Tochangethecolorofanytextonthepage,firstfindthetagresponsibleforstylingthattext,andthengointothestylesheetandmodifythecorrespondingclass,orcreateanewclass.Here’sanexample;sayyouwanttochangethecoloroftheheadersaying“AtYourService.”Currently,it’sblack,andthisisthecodehandlingit:AtYourService Tochangeitscolor,thebestwayistocreateanewclasscalled,say,.text-orangeandsetthecolorvaluethere,likeso:.text-orange{ color:#f4623a!important; } *The!important willmakesurethatthiscolorsettingwilloverwriteanyothercolorsettingthatcamebeforeit.Now,wecangobacktoourheader,andchangeitscodeto:AtYourService Withthesechanges,theheaderwillnowbeorange:Tochangethefontanditssize,youcandosomethingverysimilar.Butfirst,anexampleofwhatafontdefinitionblocklookslikeinCSS:.SOMECLASS{ font-family:"Merriweather",Roboto,sans-serif; font-size:18px; } loadfontsMerriweather,Roboto,andasystem-defaultsans-seriffont(readthistolearnaboutweb-safefonts)setthefontsizeto18pxThissortofdefinitioncanbeplacedintoanyCSSclass,justlikethecolordefinition.Actually,fontandcolordefinitionsareoftenfoundinthesameclassdeclarations.Goingbacktoourpreviousexample,tochangethefontsizeforthatheaderthatsays“AtYourService,”wecouldfirstcreateaclasslikethis:.text-xxl{ font-size:50px; } Andthenassignthisclasstotheheader:AtYourService WhenchangingthecolorsorfontsinyourBootstrap-madetemplate,firstlookthroughtheCSSstylesheetforclassesthatmightalreadyprovideyouwithalternativesizesorcolors.Usethosewhereavailable.10.CreateAdditionalPagesNowthatyouhavethehomepagecustomized,it’stimetostartworkingonsomeadditionalpagesandthenlinkthemtothehomepage.WhencreatingawebsitewithHTMLandCSS,youcanbuildanynumberofsub-pagesandthenlinkthemalltogether.Herearesomeofthecommonpagesthatmostwebsitesneed:aboutpagecontactportfolioproducts/servicesteampolicies(privacypolicy,terms,etc.)1.StartWiththeLayoutWhenbuildinganewwebpage,thefirstdecisionyouhavetomakeiswhatyouwantthelayouttobe.WhencreatingawebsitewithHTMLandCSS,nothingisstoppingyoufromcraftingwhateverlayoutyouwant.Theonlydifficultyisactuallyputtingittogether.HTMLandCSScanbetoughtodealwithwhenstartingfromablankscreen,sowe’regoingtouseBootstraphereaswell.First,we’regoingtoshowyousomeprinciplesofcraftingalayoutandthendemonstratehowtodoitwithBootstrap.Thewayyoucanthinkofyourwebpage’slayoutistoconsideritasequenceofindividualblocks–oneontopofanother.Somethinglikethis(noticethefourdistinctblocks):ThegreatthingaboutBootstrapisthatithandlesthebasiclayoutprinciplesandappearancedetailsforyousothatyoucanjustfocusonputtingthoseblocksintherightplaces.Inthissectionoftheguide,we’regoingtocreateanew“about”page.Tobegin,we’llcreatejustaverybasicprojectofthelayout.Somethingliketheoneabove.there’sanavigationmenuatthetop,afull-widthheadlineblockbelowthemenu,themaincontentsectioninthemiddle,boxedinthecenterofthescreen(notfull-width),andafooter.Nowlet’sbuildthislayoutinHTML.2.BuildaNewPageTheeasiestwaytostartworkingonanewpageistoduplicateanexistingpageanduseitasatemplate.That’swhatwe’regoingtodo.Createacopyoftheindex.htmlfileandrenameitabout.html.Justtomakethepageseasiertodistinguishatthisearlystage,editthenewabout.htmlfileandchangewhat’sinthetag.Forexample,<title>AboutMe.Nowlet’sgothroughthefilelinebylineanddecidewhatwe’llleaveandwhatwe’llremove:Thenavigationmenu(below).Youprobablywanttokeepthissectionintact,justtomakethenavigationexperienceuniformonallpages.Themainherosection(below).Thisonewewon’tneedaccordingtoourlayoutproject.Youcangoaheadanderasethewholesection.Theaboutsection(below).We’regoingtoreusethissectionasourmainheadlineblock.Theservicessection,portfoliosection,calltoactionsection,andcontactsection(everythingbetweenand).Wedon’tneedthesesectionsatall.Youcangoaheadanderasethem.Thefootersectionandeverythingbelowit(below).Thiswe’llneedtokeep.Thismakesourcurrentcodequitesimple.Itbasicallyisjustthis:

Thethingthatwe’remissinghereisthemaincontentsection.Tobuildit,we’regoingtoreusetheaboutsection.Goaheadandmakeacopyoftheaboutsection.Thisone: ... ...

Nowchangethefirsttwolinestothis: Sincewedon’tneedthe

headerthereandthe
element,let’sjustremovethem.Theonlythingleftinsidethiswholeblockisgoingtobeaparagraphoftext.Likeso:

Aparagraphoftext.

Whenyousavethefileandnavigatetoitviayourbrowser,you’llseethatyoubasicallyhavetwoverysimilarblocksonebelowtheother,withthesamecolorbackground:It’dbebettertohaveawhitebackgroundinthemaincontentsection.Tochangeit,theonlythingweneedtodoisremovethebg-primaryclassfromthemain
tag.Inotherwords,makethetagintothis: That’sbetter:Let’saddsomedummyparagraphstothepagetopopulateitsomemore,plusmaybeasub-head:

Loremipsumdolorsitamet,consecteturadipiscingelit...

Proinfermentum,felistemporpharetralobortis,magnaquamhendreritdolor...

Subhead

Loremipsumdolorsitamet,consecteturadipiscingelit...

Here’swhatthislookslikeonthepage:Ifyoudon’tlikethetexttobecenteredthenjustremovethetext-centerclassfromoneofthe
tags.Ifyouwanttoputsomemoreflairontheseblocksoftext,youcancreatenewCSSclasses(likebefore)andassignthemtotheparagraphsintheblock.Or,youcanhaveapeekintothecurrentstylesheetandseewhatclassesarealreadythereforthispurpose.Herearetheonesweassignedtothe

and

tags:Loremipsumdolorsitamet... Proinfermentum,felistemporpharetralobortis,magnaquamhendreritdolor... Subhead

Andhere’stheeffect:Onemorethingwe’regoingtodohereisaddanimagesomewhereonthepage.Here’swhatanexampleimagetaginHTMLlookslike: Fairlysimple,right?Theonlyparameterthereisthepathtotheimagefile.Tokeepthingsnicelyorganized,youcanputyourimageintheimgdirectoryagain(justlikeyoudidwiththatbackgroundawhileago).Insuchacase,theimagetagwillbe: Thatbeingsaid,theimagetaginthisparticularconfigurationisfairlylimited.Tomakeitabitmorerefined,let’sassignsomeBootstrapclassestoit.Particularly: Thesetwoclasseswillgiveyourimageroundedcornersandwillalsomakesurethatthesizeoftheimagedoesn’texceedthesizeoftheblockwhereitsits.Youcannowaddataglikethissomewhereinthemaincontentsectionofyouraboutpage.Forexample,here:Loremipsumdolorsitamet... Proinfermentum,felistemporpharetralobortis,magnaquamhendreritdolor... Subhead Andhere’sthefinaleffectonthepage:Here’souraboutpageinallitsglory:3.LinktotheNewPageWiththenewpagedone,let’snowlinkitfromthehomepage(theindex.htmlfile).Naturally,thebestplacetoaddthislinkisinthenavigationmenu(below).Inparticular,lookforthisline:About We’regoingtochangeittothis:About Thisissomethingwehaven’ttalkedaboutyet,butthetagisalinktaginHTML.Usingit,youcanlinktoanywebpagebyprovidingtheaddressofthatpageinthehrefparameter.Thetextofthelink–theclickablepartofthelink–willbethetextbetweentheopeningandclosingtags.Whenyourefreshthehomepagenow,you’llseeyournewlinkpointingtotheaboutpage.FurtherReadingAtthisstage,you’vebasicallybuiltyourselfasimplewebsiteconsistingoftwopages–ahomepageandanaboutpage.Whatyoushoulddonowisrinseandrepeatbycreatingnewpages,tuningthemup,addingcontenttothem,andthenlinkingeverythingfromthenavigationmenu.Otherthingsworthdoingasyou’regoingthroughthesestepsisfurtherlearningHTMLandCSSprinciples,goingthroughthechecklist,andalsolearningBootstrapanditsstructuresandclasses.Someresourcesforthat:HTML5cheatsheetCSScheatsheetJavascriptcheatsheetHTMLtutorialBootstraptutorialBootstrapcheatsheetMasteringBootstrap,highlylikelythebestpathcurrentlyavailabletobuildingoptimizedandbeautifulwebsiteswithHTMLandCSS.IfyouhaveanyquestionsaboutcreatingawebsitewithHTMLandCSS,don’thesitatetosubmittheminthecomments.Relatedcontent:HowtoMakeaWebsiteHowtoStartanOnlineStoreHowtoBuildanOnlinePortfolioShouldYouCreateaBlogoraWebsite10BestWebsiteBuilders(Reviewed)HowtoMakeaForumWebsiteMorecategories:WebsiteBuildingWebsiteBuildersWebsiteHosting';ClicktoLoadCommentsClosesearchform✕



請為這篇文章評分?