SASS vs LESS vs SCSS - That are the differences - Ionos

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

Both preprocessors share some of the same properties: Both SASS and LESS allow for the use of mixins and variables. One difference, though, is ... IONOSDigitalguideWebsitesWebdevelopmentSASS 12.10.20Webdevelopment WithCSS,youcandesignyourwebsiteexactlythewayyouwantit.Butthestylesheetlanguagehasitslimits.Manywebdesignerswishforamorecomfortablewaytoworkonwebsitedesign.ThisiswhereCSSpreprocessorscomeintoplay.Withthehelpofastylesheetlanguage,whichisanextensiontotheunderlyingCSS,designworkcanbemadesignificantlyeasier.Themostwell-knownoftheseextensionlanguagesisSASS.Whatexactlyisthe“SyntacticallyAwesomeStyleSheet”?ContentsWhatisSASS?WhydoyouneedSASS?FromSASStoCSSSCSSvs.SASS:whatarethedifferences?AdvantagesanddisadvantagesofSASSSASSvs.LESS–acomparisonofthetwopreprocessorsWhatisSASS?TounderstandwhatSASSisandwhyyoumightneedthelanguage,youshouldfirstmakesenseofCSS.WebsitesareinitiallybasedonthemarkuplanguageHTML.IfyouwanttodesigninHTML,thenyouhavetolinkthecontentdirectlytothedesign–oneverysingleHTMLpage.Simplysaid,HTMLisnotintendedfordesign,andsoisseverelylimitedinthisarea.Cascadingstylesheets(CSS)setthepresentationofHTMLpages.CSSsitsontopoftheHTMLcode,likeatemplate,anddefinesthedesignforeachelementonthepage:Font,fontcolor,background–webdesignerscansetallofthesedesignelementswithCSS.Forexample,tosetallheadlinesin22ptCalibri,definethisinthestylesheetwhereallguidelinesfortheappearanceofyourwebsitearegiven.Theserulesareusuallyinaseparatefile,whichtheHTMLpagesthenreferto.Thisenormouslyshortenstheamountofinformationperpage.ButCSShasitslimits,whichisespeciallyclearifyou’vebeenworkingwiththelanguageformanyyears.TheadvantageofCSSisactuallyadisadvantageatthesametime:thelanguageisdesignedverysimply.SASSmakesitallalittlemoresophisticated,andgreatlysimplifiestheworkofcreatingadesign.AllmodernbrowserscandisplayCSSwithnoerrors,butthat’snotnecessarilythecaseforSASS(whichhasbeeninuseforover10years)orotherextendedstylesheetlanguages.Forthisreason,SASSisconsideredapreprocessor.ThecodeintheSASSdocumentisfirstconvertedtoCSSbeforethesourcecode,i.e.thewebsite,isdeliveredtothesystem.FactThelanguageofSASSiscalledSassScript.ThepreprocessorwasoriginallybuiltonthemarkuplanguageYAMLbeforeitwasintroducedasitsownscriptlanguage.WhydoyouneedSASS?Atfirst,theredoesn’tseemtobeanyreasonthatSASSisnecessary.Afterall,CSShasmadeitpossibletodevelopattractivelydesignedandtechnicalpagesfordecades.EvenifyouwanttoworkwithSASSfromhereonout,youcan’tavoidCSS.Theold-fashionedstylesheetlanguagewillcontinuetostickaroundinthefutureasthefoundationofthepresentation.SASSandotherlanguagessimplybuildontheskeletonofCSS.Ofcourse,withSASSyouhavesomeoptionsthataren’tofferedbyCSSalone:Variables:WithSASS,youcansaveinformationinvariablestobeusedagainlater.Soit’spossible,forexample,tocentrallystoreacolorvalueunderacatchiervariable.Mathematicalfunctions:InSASS,youcanalsousemathematicaloperationslike+,-,*,/,or%.Thisallowsyoutoinfluencesizespecifications,forexample.Functions:Otherfunctionsalsomakeiteasiertoworkonthedesign.Theseallowyoutomodifycolorvaluesoranalyzelists,amongotherthings.Loops:AnotheradvantageofSASSistheabilitytosetuploops.Thesearerepeateduntiltheyreachastatusdefinedbyyou.Casedistinctions:Thesehaveasimilarfunctiontotheconditionalinstructions“if”and“else.”Thegivencommandsareonlyrunifspecificconditionsaremet.Mixins:Mixins,simplysaid,aretemplates.Youcaneithercreatethemyourselforsimplyintegratethemintoyourowncodewhenusingaframework.Indentations:TheoriginalSASS(asopposedtoSCSS)workswithindentationsandlinebreakstostructurethecode.Youdon’tneedparenthesestodisplaynestingorsemicolonstomarklineends.Nesting:CSSdoesn’tallowyoutoworkwithnestinginthecode.SASS,though,givesuserstheoptiontopresentdependenciesvisuallytoreduceredundanciesandsimplifythewritingprocess.Inheritances:It’spossibletoinheritpropertiesfromoneselectortoanother.Thissavessomewritingeffortandkeepsthecodeslimmer.Partialfiles:TointegratecodeelementsintoaSASSfile,youcanalsousepartials.ThesearefilesthatonlyhavetocontainafewlinesofCSSandareimportedintoaSASSfilebycommand.HelpfulframeworksandlibrariesalreadyexistforSASS.CompassorBourbondoalotoftheworkforyouwhendesigningawebsite.FactSASSisavailableundertheMITlicenseandisopensource.Buttherearealsootherimplementationsofthelanguagethatareavailableunderproprietarylicenseswhicharesometimeseasiertohandle.FromSASStoCSSSothatthecreatedSASScodehasthedesiredeffect,youfirsthavetoconvertitintoordinaryCSS.Thecompilationfunctionsveryeasilyoverthecommandline:sassexample.sass:example.cssThiscommandcompilesthesourcecodefromyourcreatedexample.sassfileintoanewCSSfile.Indoingso,thesyntaxofSASSisautomaticallymodifiedtofittherulesofCSS.Forexample,inheritanceisdoneawaywithandthesyntaxisadjusted.Workonawebsiteisrarelyfinished,andyoucouldpotentiallymakeregularchangestothedesign.ThisiswhySASSusesthe“--watch"parametertogiveyoutheoptiontomonitorfoldersorfiles.Ifyoumakechangestothem,thenthesystemautomaticallyrecompilesthem.SCSSvs.SASS:whatarethedifferences?There’snotonlyonesyntaxthatyoucanuseSASSin,buttwo:Onehastheoriginalform,whichisusuallyreferredtoas“indentedsyntax”orsimply“SASS”forshort.Butthereisalsoanewvariant,whichismorestronglyorientedtothestandardsofCSSandsoiscalledsassyCSS(SCSS)–so,SASS-styleCSS.Version3ofSASShasSCSSasanofficialsyntax.Thebiggestdifference:theuseofparenthesesandsemicolons.TheoriginalSASSsyntaxworkswithindentsandlinebreaks,aprocessadaptedfromYAML.Tofinishalineofcode,it’ssufficienttoinsertalinebreak–sopresstheenterkey.Indentsfunctionsimplyusingthetabbutton.Groupings,calleddeclarationblocks,areformedbychangingthepositioninthetypeface.Thisisn’tpossiblewithCSSitself.Here,youhavetouseparenthesesforthegroupingsandsemicolonsforthepropertydeclarations.Thisisexactlywhat’snecessaryforSCSS.Thevariationscommandfierceloyalty:SomeusersswearbythesimplehandlingoftheoriginalSASS,whereyoudon’thavetopayattentiontothecorrectpositioningoftheparentheseswhenmovingsnippetsofsourcecodeandcangenerallycreateslimmer,clearercode.Youendupwithfewercharactersandlinesoverallasaresultofthe“indentedsyntax.”TheSCSSenthusiasts,ontheotherhand,arehappytotaketheadditionaleffortinstride,becauseit’smoresimilartowhatyoualreadyknowfromusingCSS.SCSSisasupersetofCSS,whichguaranteesthattheCSScodefundamentallyworksinSCSSaswell–butnottheotherwayaround.ThefunctionsofSASSarestillfullycontained,though.Thismakesiteasiertoworkwithbothlanguagesatthesametime.Inaddition,peoplewhoalreadyworkwithCSSandarecomfortablewiththesyntaxhaveamucheasiertimeswitchingover.EventhoughSASSsupportsbothsyntaxes,youstillhavetodecideforeachproject:tobeabletodistinguishbetweenthedifferentformats,givethefileseitherthefileending“.sass”or“.scss.”AdvantagesanddisadvantagesofSASSSASSbringsalotofbenefitstothetable,butthepreprocessorstilldoesn’tconvinceeveryone.Theadvantagesareobvious:Thepreprocessorlanguagegivesusersmorepossibilitieswhencreatingcode.Manywebdesigners,forexample,lovethefunctionthatallowsyoutostorecolorsasvariablesinsteadofalwayshavingtoenterthecolorvalueasahexadecimalnumber.Mixins,variables,inheritance,andnestingdoabetterjobthantraditionalCSSinensuringthatyoufollowtheprinciple“Don’trepeatyourself.”Thistheorypushesforavoidingrepetitionincodeandkeepingsourcecodeslimmer.Thesechangesalsosignificantlyreducetheeffortrequired.Insteadofhavingtomakechangesinmultipledifferentplaces,youcanjustmakeonechangeatacentralposition.ThedisadvantagesofSASSapplytobasicallyeverypreprocessor,andrefertothefactthatthecreatedcodefirsthastobecompiled.Thisaddsanothersteptothedevelopmentprocess.Thismakestheprocessabitlengthier.InsteadofbeingabletomakemodificationsdirectlyintheCSSfileandseetheeffectsimmediatelyonthewebsite,changesinthedesignfirsthavetobetranslatedintoCSS.Thisallowserrorstoslipinandmakesdebuggingmoredifficult.BeforeusingSASS–justlikewithanyotherunfamiliartechnology–youneedtotakethetimetolearnthenewlanguage.InadditiontoCSS,whichyoushouldalreadyknowinanycase,it’ssimplyanotherlanguagetomaster. Advantages Disadvantages   Morepossibilities Codehastobecompiled   Clearcode Difficulttroubleshooting   Extensiveframeworks Higherlearningeffort   Workwithmixinsandvariables     SASSvs.LESS–acomparisonofthetwopreprocessorsInadditiontoSASS,LESShasalsoestablisheditselfindevelopercircles.ThisstylesheetlanguageisstronglyorientedaroundCSSandresemblesSCSSinitssyntax.Bothpreprocessorssharesomeofthesameproperties:BothSASSandLESSallowfortheuseofmixinsandvariables.Onedifference,though,isthatSASSisbasedonRuby,whileLESSusesJavaScript.Buteventhisdoesn’tgiveeitherofthepreprocessorsanadvantageovertheothers.Therealdifferencesarefoundinsteadinthelogicalfunctions:LESSgivesuserstheopportunitytoonlyactivatemixinswhenspecificsituationsoccur.Thisisahelpfulfeature,butitrepresentstheextentoflogicallinksinLESS.SASS,ontheotherhand,offersloopsandcasedistinctionsasknownfromprogramminglanguages.WithSASS,usersarefreetochoosebetween“indentedsyntax”orSCSS.EachdevelopercandecideforthemselveswhethertheywouldliketomoveawayfromtheCSSrulesorstayclosertotheoriginal.LESSdoesn’tofferthischoice.Here,usershavetostickwiththeoldrules.CodeinLESSisautomaticallyasupersetofCSS:AllsourcetextformulatedinCSSalsofunctionsinLESS–justlikewithSCSS.SASSismuchmorepopularamongwebdesigners.ButthiscouldbebecauseSASSisabitolder.LESSwasoriginallysupportedbythewell-regardedfrontendframeworkBootstrap,whichreliedontheyoungerpreprocessor.Butwithversion4,theprojectofficiallyswitchedtoSASS,whichboostedthepopularityofsyntacticallyawesomestylesheetsevenfurther.12.10.20WebdevelopmentCSSRelatedarticlesCSStricks:usefulsnippetsforyourwebproject07.10.2020Webdesign ThestylesheetlanguageCSSisoneofthemostimportanttoolsofmodernwebdevelopment.Itmakesitpossibletoseparateawebsite’scontentandlayoutfromoneanotherandiscontinuouslybeingdevelopedbytheWorldWideWebConsortium(W3C).CSSsnippetsfacilitatethedesignofwebpagessignificantlyandcaneventakeonfunctionsofPhotoshopandJavaScript.Here,werevealsomeusefulCSS... CSSTutorial:AnintroductiontoCascadingStyleSheets26.03.2019Webdesign WithoutCSS,websiteswouldjustbeacollectionoftextelementsseparatedbyheadlinesandparagraphs.OnlytheabilitytoformatHTMLusingcascadingstylesheetsmaketheinternetwhatitistoday:acolorfulmixofcustomizedonlinepresences,fromtheambitioushomehobbypagetotheaward-winningdesignwebsite.OurCSStutorialwalksyouthroughthesecretsofthestylesheetlanguagewith... Continuousintegration:definition28.01.2020Webdevelopment Acommoncomplaintwhenitcomestosoftwaredevelopment:thelengthyintegrationphaseattheend,includingtroubleshootingthatcanbequitelaborious.Continuousintegrationeliminatesthistediousprocessbyprovidinggranular,continuousintegration.Eachnewfunctionisinserteddirectlyintothecodebase–sometimesseveraltimesaday.Theteamisthereforealwaysuptodateandcan... Thisisaheadline12.07.2021Webdesign CascadingStyleSheets(CSS)isastylesheetlanguage.TogetherwithHTML,CSSgivesyoutheoptiontoprocessawebsitevisually.CSSwasdevelopedtoseparatepresentationspecificationssuchasfontsandtheshapeandcolorofelementsfromotherwebsitecontent.LearnhowtouseCSShere. RelatedproductsDomainNamesSeepackages WebhostingforagenciesProvidepowerfulandreliableservicetoyourclientswithawebhostingpackagefromIONOS.Viewpackages PopularArticles WordPressblogthemes SpecialWordPressblogthemesletyoucreateinterestingandvisuallystunningonlinelogs...InstructionsfordisablingWordPresscomments Youcanturnoffcommentsforindividualpagesorpostsorforyourentirewebsite.Keepreadingtofindouthow...WordPress:AMPPlugins WewillshowyouthebestAMPpluginsforWordPressataglance...CreatingawebsitewithWordPress:aBeginner’sGuide OurWordPressguidewillguideyoustep-by-stepthroughthewebsitemakingprocess...AddingGoogleAnalyticstoWordPress Here,you’llfindouthowyoucanlinkGoogleAnalyticstoawebsitewhilealsoensuringdataprotection... Wait!We’vegotsomethingforyou! Havealookatourgreatpricesfordifferentdomainextensions.Enterthewebaddressofyourchoiceinthesearchbartocheckitsavailability.CheckVisitshop.org$1/1styear then$20/year.com$1/1styear then$15/year.info$1/1styear then$20/year.me$1/1styear then$20/year



請為這篇文章評分?