{"id":2311,"date":"2015-10-02T18:00:10","date_gmt":"2015-10-02T18:00:10","guid":{"rendered":"http:\/\/tutorialsclass.com\/?p=2311"},"modified":"2020-06-20T10:26:59","modified_gmt":"2020-06-20T10:26:59","slug":"css-syntax","status":"publish","type":"post","link":"https:\/\/tutorialsclass.com\/css-syntax\/","title":{"rendered":"CSS Syntax"},"content":{"rendered":"\n<p>A CSS code or document is basically a set of style rules. We apply these CSS Rules for the formatting of HTML Page.<\/p>\n\n\n\n<p>For example, we can change the size of text or background color of HTML web page using CSS.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Basic CSS Syntax<\/h3>\n\n\n\n<p>Each CSS rule made up of <strong>Selector <\/strong>part and <strong>Declaration <\/strong>part. Declaration part is a combination of CSS Property and Value. To write a CSS Rule, we start with a<code> \"selector\"<\/code>, and then have a bracket {} containing a sequence of declarations.<\/p>\n\n\n\n<p>The basic CSS Syntax is defined as:<\/p>\n\n\n\n<p class=\"lang:css crayon-inline\"><code>selector { property : value; }<\/code><\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">Description of CSS Syntax<\/h3>\n\n\n\n<ul class=\"wp-block-list\"><li><strong> Selector: <\/strong><p>We place HTML tag name here. You can specify which tag you want to style, for example:<code> \"body\", \"h1\", \"div\", and \"p\"<\/code>.<\/p> <\/li><li><strong> Property: <\/strong><p>A property is a type of attribute (like a feature) of HTML tag. An example of HTML property are:<code> color, font-size &amp; border<\/code>.<\/p> <\/li><li> <strong>Value: <\/strong><p>Each property has a set of value. We can specify that value here. For example, &#8220;color&#8221; attribute value will be color name:<code> \"red\" or \"green\"<\/code>.<\/p> <\/li><\/ul>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<h4 class=\"wp-block-heading\">CSS Syntax Example:<\/h4>\n\n\n\n<p>Let us have a CSS rule to set all text color red inside paragraph tag.<\/p>\n\n\n\n<pre class=\"wp-block-code language-markup\"><code>p {\ncolor: red;\n}<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">Complete CSS Example in HTML Program:<\/h3>\n\n\n\n<p>Now, we will see a complete example of using CSS Rules in HTML Document.<\/p>\n\n\n\n<p>You can define Different CSS rules for multiple tags in the same documents. Each CSS Rule declaration block can contain one or more declarations separated by semicolons.<\/p>\n\n\n\n<pre class=\"wp-block-code language-markup\"><code>&lt;!DOCTYPE html>\n&lt;html>\n&lt;head>\n&lt;style>\nbody {\n    background-color: green;\n}\n\np {\n    color: yellow;\n    font-size: 25px;\n}\n&lt;\/style>\n&lt;\/head>\n&lt;body>\n\n&lt;p> This is a Sample text inside p tag. Welcome to Tutorials Class. &lt;\/p>\n\n&lt;\/body>\n&lt;\/html><\/code><\/pre>\n\n\n\n<p> <\/p>\n\n\n\n<p>In the above example, we have created a CSS rule that defines all text inside the paragraph tag will have font-size 25px and text color will be red. There is another CSS Rule that will set the HTML Page body&#8217;s background color green.<\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p>We have used a paragraph<code> (p)<\/code> element as a selector to select an HTML Element. This is called <strong>Element Selector<\/strong>. There are many other CSS Selectors available such as <strong>class Selector<\/strong> and <strong>id Selector<\/strong>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>A CSS code or document is basically a set of style rules. We apply these CSS Rules for the formatting of HTML Page. For example, we can change the size of text&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"keywords":[],"class_list":["post-2311","post","type-post","status-publish","format-standard","hentry","category-css"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.1.1 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>CSS Syntax - Learn CSS Selector with Example - Tutorials<\/title>\n<meta name=\"description\" content=\"The basic CSS Syntax block is: selector { property:value; } - CSS can be specify with class, id or element Selector. Learn CSS Syntax rules with examples\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/tutorialsclass.com\/css-syntax\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"CSS Syntax - Learn CSS Selector with Example - Tutorials\" \/>\n<meta property=\"og:description\" content=\"The basic CSS Syntax block is: selector { property:value; } - CSS can be specify with class, id or element Selector. Learn CSS Syntax rules with examples\" \/>\n<meta property=\"og:url\" content=\"https:\/\/tutorialsclass.com\/css-syntax\/\" \/>\n<meta property=\"og:site_name\" content=\"Tutorials Class\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/tutorialsclass\" \/>\n<meta property=\"article:published_time\" content=\"2015-10-02T18:00:10+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2020-06-20T10:26:59+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/tutorialsclass.com\/wp-content\/uploads\/2020\/07\/tutorials-class-logo.png\" \/>\n\t<meta property=\"og:image:width\" content=\"600\" \/>\n\t<meta property=\"og:image:height\" content=\"600\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Tutorials Class\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@TutorialsClass\" \/>\n<meta name=\"twitter:site\" content=\"@TutorialsClass\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Tutorials Class\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/tutorialsclass.com\/css-syntax\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/tutorialsclass.com\/css-syntax\/\"},\"author\":{\"name\":\"Tutorials Class\",\"@id\":\"https:\/\/tutorialsclass.com\/#\/schema\/person\/f7d4f67fc9721ef3ea91cb21aaf89e3e\"},\"headline\":\"CSS Syntax\",\"datePublished\":\"2015-10-02T18:00:10+00:00\",\"dateModified\":\"2020-06-20T10:26:59+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/tutorialsclass.com\/css-syntax\/\"},\"wordCount\":300,\"publisher\":{\"@id\":\"https:\/\/tutorialsclass.com\/#organization\"},\"articleSection\":[\"CSS Tutorial\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/tutorialsclass.com\/css-syntax\/\",\"url\":\"https:\/\/tutorialsclass.com\/css-syntax\/\",\"name\":\"CSS Syntax - Learn CSS Selector with Example - Tutorials\",\"isPartOf\":{\"@id\":\"https:\/\/tutorialsclass.com\/#website\"},\"datePublished\":\"2015-10-02T18:00:10+00:00\",\"dateModified\":\"2020-06-20T10:26:59+00:00\",\"description\":\"The basic CSS Syntax block is: selector { property:value; } - CSS can be specify with class, id or element Selector. Learn CSS Syntax rules with examples\",\"breadcrumb\":{\"@id\":\"https:\/\/tutorialsclass.com\/css-syntax\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/tutorialsclass.com\/css-syntax\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/tutorialsclass.com\/css-syntax\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/tutorialsclass.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Learn\",\"item\":\"https:\/\/tutorialsclass.com\/learn\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"CSS Tutorial\",\"item\":\"https:\/\/tutorialsclass.com\/learn\/css\/\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"CSS Syntax\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/tutorialsclass.com\/#website\",\"url\":\"https:\/\/tutorialsclass.com\/\",\"name\":\"Tutorials Class\",\"description\":\"Online Tutorials for Beginners\",\"publisher\":{\"@id\":\"https:\/\/tutorialsclass.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/tutorialsclass.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/tutorialsclass.com\/#organization\",\"name\":\"Tutorials Class\",\"url\":\"https:\/\/tutorialsclass.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/tutorialsclass.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/tutorialsclass.com\/wp-content\/uploads\/2020\/05\/tutorials-class-logo.png\",\"contentUrl\":\"https:\/\/tutorialsclass.com\/wp-content\/uploads\/2020\/05\/tutorials-class-logo.png\",\"width\":442,\"height\":94,\"caption\":\"Tutorials Class\"},\"image\":{\"@id\":\"https:\/\/tutorialsclass.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/tutorialsclass\",\"https:\/\/x.com\/TutorialsClass\",\"https:\/\/in.pinterest.com\/merientinfotech\/boards\/\",\"https:\/\/www.youtube.com\/channel\/UCzbpQXlqec-bQf1_kwrTuoA\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/tutorialsclass.com\/#\/schema\/person\/f7d4f67fc9721ef3ea91cb21aaf89e3e\",\"name\":\"Tutorials Class\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/tutorialsclass.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/346276d8e1600eec36df1bf9adcf78bf1eabb87fc0a79250e0565a88809b8f14?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/346276d8e1600eec36df1bf9adcf78bf1eabb87fc0a79250e0565a88809b8f14?s=96&d=mm&r=g\",\"caption\":\"Tutorials Class\"},\"sameAs\":[\"tcadmin\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"CSS Syntax - Learn CSS Selector with Example - Tutorials","description":"The basic CSS Syntax block is: selector { property:value; } - CSS can be specify with class, id or element Selector. Learn CSS Syntax rules with examples","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/tutorialsclass.com\/css-syntax\/","og_locale":"en_US","og_type":"article","og_title":"CSS Syntax - Learn CSS Selector with Example - Tutorials","og_description":"The basic CSS Syntax block is: selector { property:value; } - CSS can be specify with class, id or element Selector. Learn CSS Syntax rules with examples","og_url":"https:\/\/tutorialsclass.com\/css-syntax\/","og_site_name":"Tutorials Class","article_publisher":"https:\/\/www.facebook.com\/tutorialsclass","article_published_time":"2015-10-02T18:00:10+00:00","article_modified_time":"2020-06-20T10:26:59+00:00","og_image":[{"width":600,"height":600,"url":"https:\/\/tutorialsclass.com\/wp-content\/uploads\/2020\/07\/tutorials-class-logo.png","type":"image\/png"}],"author":"Tutorials Class","twitter_card":"summary_large_image","twitter_creator":"@TutorialsClass","twitter_site":"@TutorialsClass","twitter_misc":{"Written by":"Tutorials Class","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/tutorialsclass.com\/css-syntax\/#article","isPartOf":{"@id":"https:\/\/tutorialsclass.com\/css-syntax\/"},"author":{"name":"Tutorials Class","@id":"https:\/\/tutorialsclass.com\/#\/schema\/person\/f7d4f67fc9721ef3ea91cb21aaf89e3e"},"headline":"CSS Syntax","datePublished":"2015-10-02T18:00:10+00:00","dateModified":"2020-06-20T10:26:59+00:00","mainEntityOfPage":{"@id":"https:\/\/tutorialsclass.com\/css-syntax\/"},"wordCount":300,"publisher":{"@id":"https:\/\/tutorialsclass.com\/#organization"},"articleSection":["CSS Tutorial"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/tutorialsclass.com\/css-syntax\/","url":"https:\/\/tutorialsclass.com\/css-syntax\/","name":"CSS Syntax - Learn CSS Selector with Example - Tutorials","isPartOf":{"@id":"https:\/\/tutorialsclass.com\/#website"},"datePublished":"2015-10-02T18:00:10+00:00","dateModified":"2020-06-20T10:26:59+00:00","description":"The basic CSS Syntax block is: selector { property:value; } - CSS can be specify with class, id or element Selector. Learn CSS Syntax rules with examples","breadcrumb":{"@id":"https:\/\/tutorialsclass.com\/css-syntax\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/tutorialsclass.com\/css-syntax\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/tutorialsclass.com\/css-syntax\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/tutorialsclass.com\/"},{"@type":"ListItem","position":2,"name":"Learn","item":"https:\/\/tutorialsclass.com\/learn\/"},{"@type":"ListItem","position":3,"name":"CSS Tutorial","item":"https:\/\/tutorialsclass.com\/learn\/css\/"},{"@type":"ListItem","position":4,"name":"CSS Syntax"}]},{"@type":"WebSite","@id":"https:\/\/tutorialsclass.com\/#website","url":"https:\/\/tutorialsclass.com\/","name":"Tutorials Class","description":"Online Tutorials for Beginners","publisher":{"@id":"https:\/\/tutorialsclass.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/tutorialsclass.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/tutorialsclass.com\/#organization","name":"Tutorials Class","url":"https:\/\/tutorialsclass.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/tutorialsclass.com\/#\/schema\/logo\/image\/","url":"https:\/\/tutorialsclass.com\/wp-content\/uploads\/2020\/05\/tutorials-class-logo.png","contentUrl":"https:\/\/tutorialsclass.com\/wp-content\/uploads\/2020\/05\/tutorials-class-logo.png","width":442,"height":94,"caption":"Tutorials Class"},"image":{"@id":"https:\/\/tutorialsclass.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/tutorialsclass","https:\/\/x.com\/TutorialsClass","https:\/\/in.pinterest.com\/merientinfotech\/boards\/","https:\/\/www.youtube.com\/channel\/UCzbpQXlqec-bQf1_kwrTuoA"]},{"@type":"Person","@id":"https:\/\/tutorialsclass.com\/#\/schema\/person\/f7d4f67fc9721ef3ea91cb21aaf89e3e","name":"Tutorials Class","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/tutorialsclass.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/346276d8e1600eec36df1bf9adcf78bf1eabb87fc0a79250e0565a88809b8f14?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/346276d8e1600eec36df1bf9adcf78bf1eabb87fc0a79250e0565a88809b8f14?s=96&d=mm&r=g","caption":"Tutorials Class"},"sameAs":["tcadmin"]}]}},"_links":{"self":[{"href":"https:\/\/tutorialsclass.com\/wp-json\/wp\/v2\/posts\/2311","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/tutorialsclass.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/tutorialsclass.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/tutorialsclass.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/tutorialsclass.com\/wp-json\/wp\/v2\/comments?post=2311"}],"version-history":[{"count":6,"href":"https:\/\/tutorialsclass.com\/wp-json\/wp\/v2\/posts\/2311\/revisions"}],"predecessor-version":[{"id":5890,"href":"https:\/\/tutorialsclass.com\/wp-json\/wp\/v2\/posts\/2311\/revisions\/5890"}],"wp:attachment":[{"href":"https:\/\/tutorialsclass.com\/wp-json\/wp\/v2\/media?parent=2311"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/tutorialsclass.com\/wp-json\/wp\/v2\/categories?post=2311"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tutorialsclass.com\/wp-json\/wp\/v2\/tags?post=2311"},{"taxonomy":"keywords","embeddable":true,"href":"https:\/\/tutorialsclass.com\/wp-json\/wp\/v2\/keywords?post=2311"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}