{"appState":{"pageLoadApiCallsStatus":true},"categoryState":{"relatedCategories":{"headers":{"timestamp":"2025-04-17T16:01:16+00:00"},"categoryId":34324,"data":{"title":"CSS3","slug":"css3","image":{"src":null,"width":0,"height":0},"breadcrumbs":[{"name":"Technology","_links":{"self":"https://dummies-api.dummies.com/v2/categories/33512"},"slug":"technology","categoryId":33512},{"name":"Programming & Web Design","_links":{"self":"https://dummies-api.dummies.com/v2/categories/33592"},"slug":"programming-web-design","categoryId":33592},{"name":"CSS3","_links":{"self":"https://dummies-api.dummies.com/v2/categories/34324"},"slug":"css3","categoryId":34324}],"parentCategory":{"categoryId":33592,"title":"Programming & Web Design","slug":"programming-web-design","_links":{"self":"https://dummies-api.dummies.com/v2/categories/33592"}},"childCategories":[],"description":"Give that website some style and get dynamic with the latest CSS and HTML5 standards, tricks, and workflows.","relatedArticles":{"self":"https://dummies-api.dummies.com/v2/articles?category=34324&offset=0&size=5"},"hasArticle":true,"hasBook":false,"articleCount":4,"bookCount":0},"_links":{"self":"https://dummies-api.dummies.com/v2/categories/34324"}},"relatedCategoriesLoadedStatus":"success"},"listState":{"list":{"count":4,"total":4,"items":[{"headers":{"creationTime":"2016-03-26T13:11:42+00:00","modifiedTime":"2019-11-05T20:56:20+00:00","timestamp":"2022-09-14T18:17:22+00:00"},"data":{"breadcrumbs":[{"name":"Technology","_links":{"self":"https://dummies-api.dummies.com/v2/categories/33512"},"slug":"technology","categoryId":33512},{"name":"Programming & Web Design","_links":{"self":"https://dummies-api.dummies.com/v2/categories/33592"},"slug":"programming-web-design","categoryId":33592},{"name":"CSS3","_links":{"self":"https://dummies-api.dummies.com/v2/categories/34324"},"slug":"css3","categoryId":34324}],"title":"How to Detect the User’s Browser Type in CSS3","strippedTitle":"how to detect the user’s browser type in css3","slug":"how-to-detect-the-users-browser-type-in-css3","canonicalUrl":"","seo":{"metaDescription":"In most cases, developers don’t get to choose a user’s browser. To determine whether a particular user can work with your CSS3 application, then, you need first","noIndex":0,"noFollow":0},"content":"In most cases, developers don’t get to choose a user’s browser. To determine whether a particular user can work with your CSS3 application, then, you need first to detect the user’s browser — and then determine whether that browser is acceptable.\r\n<p class=\"TechnicalStuff\">Creating the code required to perform this task by hand isn’t impossible, but it can be hard. Articles like the one at <a href=\"http://www.javascripter.net/faq/browsern.htm\">Javascripter.net</a> tell you how to perform this task, but one look at the code should tell you that it’s a complex task. (You can see the output from this example code <a href=\"http://www.javascripter.net/faq/browserv.htm\">here</a>.)</p>\r\njQuery makes it possible to perform the detection with relative ease. The following example shows one method to detect the name and version of the user’s browser. It relies on the latest 1.<i>x</i> version of jQuery, which is version 1.10.1 at the time of this writing. (You can find complete code for this example in the Chapter 06jQuery folder of the <a href=\"https://www.dummies.com/store/product/CSS3-For-Dummies.productCd-1118441427,descCd-DOWNLOAD.html\">downloadable code</a> as BrowserDetect.html.)\r\n<pre class=\"code\">&lt;!DOCTYPE html&gt;\r\n&lt;html&gt;\r\n &lt;head&gt;\r\n &lt;title&gt;Detect a Browser&lt;/title&gt;\r\n &lt;script\r\n src=\"http://code.jquery.com/jquery-latest.js\"&gt;\r\n &lt;/script&gt;\r\n &lt;script\r\n src=\"http://code.jquery.com/jquery-migrate-1.2.1.js\"&gt;\r\n &lt;/script&gt;\r\n &lt;/head&gt;\r\n &lt;body&gt;\r\n &lt;h1&gt;Browser Information&lt;/h1&gt;\r\n &lt;p id=\"name\"&gt;&lt;/p&gt;\r\n &lt;script language=\"JavaScript\"&gt;\r\n var browser =\r\n $.uaMatch(navigator.userAgent).browser;\r\n $('p[id=\"name\"]').html(\r\n \"Browser Name: &lt;span&gt;\" + browser + \"&lt;/span&gt;\");\r\n &lt;/script&gt;\r\n &lt;p id=\"version\"&gt;&lt;/p&gt;\r\n &lt;script language=\"JavaScript\"&gt;\r\n $('p[id=\"version\"]').html(\r\n \"Version Number: &lt;span&gt;\" + $.browser.version +\r\n \"&lt;/span&gt;\");\r\n &lt;/script&gt;\r\n &lt;/body&gt;\r\n&lt;/html&gt;</pre>\r\nThis is an HTML5 page, so it starts with the HTML declaration, <!DOCTYPE html>. This example begins with a basic structure that includes the <html>, <head>, <title>, and <body> tags.\r\n\r\nThe code begins with the first <script> tag that uses the src attribute to tell the browser where to find the jQuery library. You can copy this information as shown to any page where you want to use jQuery.\r\n\r\nAnyone who uses the application will automatically have access to jQuery as long as the browser can access the Internet. (You can also download a copy of jQuery for local access from the jQuery site.)\r\n<p class=\"Remember\">The latest 1.<i>x</i> version of jQuery doesn’t support the browser detection feature directly. In order to make the feature work with anything newer than jQuery 1.8.3, you must also include the link for the <a href=\"http://code.jquery.com/jquery-migrate-1.2.1.js\">jQuery Migrate library</a> as shown in the example.</p>\r\nThe <body> of the page starts out with a <h1> tag that contains the page’s heading. The next step is to provide a place for jQuery to put the browser’s name.\r\n\r\nIn this case, the example uses a <p> (paragraph) tag that has an id of name. The first <script> creates a var (variable) named browser and places the browser’s name in it. The browser name is always provided to your application as part of the JavaScript navigator.userAgent object, but working with this object is time-consuming, so this code shows a one-line method for obtaining the information.\r\n\r\nIt’s time to display the name onscreen. The $ (dollar sign) is a special symbol that refers to the jQuery library, which is also called an Application Programming Interface (API). The bit of code that says, $('p[id=\"name\"]').html, tells jQuery to use the <p> tag with an id value of name to hold some HTML. This is a kind of selector.\r\n\r\nYou now have a specific tag selected. The code then tells jQuery to create some text, a <span>, and then place the name of the browser within that span. All this information appears in the <p> tag after the script executes.\r\n\r\nNext comes a second <p> tag. This one has an id attribute of version. The accompanying script starts out the same as before. The $('p[id=\"version\"]').html entry tells jQuery to place some HTML in the <p> tag with an id attribute of version. In this case, jQuery provides what you need as a property. All the code has to do is tell jQuery to place the value in browser.version within the <p> tag to display the browser’s version number. When you run this example, you see output similar to this:\r\n\r\n<img src=\"https://www.dummies.com/wp-content/uploads/414707.image0.jpg\" alt=\"image0.jpg\" width=\"492\" height=\"194\" />\r\n<p class=\"Remember\">A library can detect only the browsers it’s designed to detect. Consequently, jQuery detects some browsers, but not others. For example, you can’t currently use it to detect an Android browser because Android isn’t in the list of browsers supported by jQuery (which focuses on desktop browsers).</p>\r\nMost browser detection methods rely on user agent strings that contain information about the browser. To see the user agent string for your browser, check out <a href=\"https://www.whoishostingthis.com/tools/user-agent/\">Who is Hosting This</a> You can generally find lists of user agent strings for devices online.","description":"In most cases, developers don’t get to choose a user’s browser. To determine whether a particular user can work with your CSS3 application, then, you need first to detect the user’s browser — and then determine whether that browser is acceptable.\r\n<p class=\"TechnicalStuff\">Creating the code required to perform this task by hand isn’t impossible, but it can be hard. Articles like the one at <a href=\"http://www.javascripter.net/faq/browsern.htm\">Javascripter.net</a> tell you how to perform this task, but one look at the code should tell you that it’s a complex task. (You can see the output from this example code <a href=\"http://www.javascripter.net/faq/browserv.htm\">here</a>.)</p>\r\njQuery makes it possible to perform the detection with relative ease. The following example shows one method to detect the name and version of the user’s browser. It relies on the latest 1.<i>x</i> version of jQuery, which is version 1.10.1 at the time of this writing. (You can find complete code for this example in the Chapter 06jQuery folder of the <a href=\"https://www.dummies.com/store/product/CSS3-For-Dummies.productCd-1118441427,descCd-DOWNLOAD.html\">downloadable code</a> as BrowserDetect.html.)\r\n<pre class=\"code\">&lt;!DOCTYPE html&gt;\r\n&lt;html&gt;\r\n &lt;head&gt;\r\n &lt;title&gt;Detect a Browser&lt;/title&gt;\r\n &lt;script\r\n src=\"http://code.jquery.com/jquery-latest.js\"&gt;\r\n &lt;/script&gt;\r\n &lt;script\r\n src=\"http://code.jquery.com/jquery-migrate-1.2.1.js\"&gt;\r\n &lt;/script&gt;\r\n &lt;/head&gt;\r\n &lt;body&gt;\r\n &lt;h1&gt;Browser Information&lt;/h1&gt;\r\n &lt;p id=\"name\"&gt;&lt;/p&gt;\r\n &lt;script language=\"JavaScript\"&gt;\r\n var browser =\r\n $.uaMatch(navigator.userAgent).browser;\r\n $('p[id=\"name\"]').html(\r\n \"Browser Name: &lt;span&gt;\" + browser + \"&lt;/span&gt;\");\r\n &lt;/script&gt;\r\n &lt;p id=\"version\"&gt;&lt;/p&gt;\r\n &lt;script language=\"JavaScript\"&gt;\r\n $('p[id=\"version\"]').html(\r\n \"Version Number: &lt;span&gt;\" + $.browser.version +\r\n \"&lt;/span&gt;\");\r\n &lt;/script&gt;\r\n &lt;/body&gt;\r\n&lt;/html&gt;</pre>\r\nThis is an HTML5 page, so it starts with the HTML declaration, <!DOCTYPE html>. This example begins with a basic structure that includes the <html>, <head>, <title>, and <body> tags.\r\n\r\nThe code begins with the first <script> tag that uses the src attribute to tell the browser where to find the jQuery library. You can copy this information as shown to any page where you want to use jQuery.\r\n\r\nAnyone who uses the application will automatically have access to jQuery as long as the browser can access the Internet. (You can also download a copy of jQuery for local access from the jQuery site.)\r\n<p class=\"Remember\">The latest 1.<i>x</i> version of jQuery doesn’t support the browser detection feature directly. In order to make the feature work with anything newer than jQuery 1.8.3, you must also include the link for the <a href=\"http://code.jquery.com/jquery-migrate-1.2.1.js\">jQuery Migrate library</a> as shown in the example.</p>\r\nThe <body> of the page starts out with a <h1> tag that contains the page’s heading. The next step is to provide a place for jQuery to put the browser’s name.\r\n\r\nIn this case, the example uses a <p> (paragraph) tag that has an id of name. The first <script> creates a var (variable) named browser and places the browser’s name in it. The browser name is always provided to your application as part of the JavaScript navigator.userAgent object, but working with this object is time-consuming, so this code shows a one-line method for obtaining the information.\r\n\r\nIt’s time to display the name onscreen. The $ (dollar sign) is a special symbol that refers to the jQuery library, which is also called an Application Programming Interface (API). The bit of code that says, $('p[id=\"name\"]').html, tells jQuery to use the <p> tag with an id value of name to hold some HTML. This is a kind of selector.\r\n\r\nYou now have a specific tag selected. The code then tells jQuery to create some text, a <span>, and then place the name of the browser within that span. All this information appears in the <p> tag after the script executes.\r\n\r\nNext comes a second <p> tag. This one has an id attribute of version. The accompanying script starts out the same as before. The $('p[id=\"version\"]').html entry tells jQuery to place some HTML in the <p> tag with an id attribute of version. In this case, jQuery provides what you need as a property. All the code has to do is tell jQuery to place the value in browser.version within the <p> tag to display the browser’s version number. When you run this example, you see output similar to this:\r\n\r\n<img src=\"https://www.dummies.com/wp-content/uploads/414707.image0.jpg\" alt=\"image0.jpg\" width=\"492\" height=\"194\" />\r\n<p class=\"Remember\">A library can detect only the browsers it’s designed to detect. Consequently, jQuery detects some browsers, but not others. For example, you can’t currently use it to detect an Android browser because Android isn’t in the list of browsers supported by jQuery (which focuses on desktop browsers).</p>\r\nMost browser detection methods rely on user agent strings that contain information about the browser. To see the user agent string for your browser, check out <a href=\"https://www.whoishostingthis.com/tools/user-agent/\">Who is Hosting This</a> You can generally find lists of user agent strings for devices online.","blurb":"","authors":[{"authorId":9109,"name":"John Paul Mueller","slug":"john-paul-mueller","description":" <p><b>John Mueller</b> has produced 114 books and more than 600 articles on topics ranging from functional programming techniques to working with Amazon Web Services &#40;AWS&#41;. <b>Luca Massaron,</b> a Google Developer Expert &#40;GDE&#41;,??interprets big data and transforms it into smart data through simple and effective data mining and machine learning techniques. ","hasArticle":false,"_links":{"self":"https://dummies-api.dummies.com/v2/authors/9109"}}],"primaryCategoryTaxonomy":{"categoryId":34324,"title":"CSS3","slug":"css3","_links":{"self":"https://dummies-api.dummies.com/v2/categories/34324"}},"secondaryCategoryTaxonomy":{"categoryId":0,"title":null,"slug":null,"_links":null},"tertiaryCategoryTaxonomy":{"categoryId":0,"title":null,"slug":null,"_links":null},"trendingArticles":[{"articleId":192609,"title":"How to Pray the Rosary: A Comprehensive Guide","slug":"how-to-pray-the-rosary","categoryList":["body-mind-spirit","religion-spirituality","christianity","catholicism"],"_links":{"self":"/articles/192609"}},{"articleId":208741,"title":"Kabbalah For Dummies Cheat Sheet","slug":"kabbalah-for-dummies-cheat-sheet","categoryList":["body-mind-spirit","religion-spirituality","kabbalah"],"_links":{"self":"/articles/208741"}},{"articleId":230957,"title":"Nikon D3400 For Dummies Cheat Sheet","slug":"nikon-d3400-dummies-cheat-sheet","categoryList":["home-auto-hobbies","photography"],"_links":{"self":"/articles/230957"}},{"articleId":235851,"title":"Praying the Rosary and Meditating on the Mysteries","slug":"praying-rosary-meditating-mysteries","categoryList":["body-mind-spirit","religion-spirituality","christianity","catholicism"],"_links":{"self":"/articles/235851"}},{"articleId":284787,"title":"What Your Society Says About You","slug":"what-your-society-says-about-you","categoryList":["academics-the-arts","humanities"],"_links":{"self":"/articles/284787"}}],"inThisArticle":[],"relatedArticles":{"fromBook":[],"fromCategory":[{"articleId":156517,"title":"How to Create External Styles in CSS3","slug":"how-to-create-external-styles-in-css3","categoryList":["technology","programming-web-design","css3"],"_links":{"self":"https://dummies-api.dummies.com/v2/articles/156517"}},{"articleId":156485,"title":"How to Use Multiple Styles Together with CSS3","slug":"how-to-use-multiple-styles-together-with-css3","categoryList":["technology","programming-web-design","css3"],"_links":{"self":"https://dummies-api.dummies.com/v2/articles/156485"}},{"articleId":142904,"title":"Using the Div Tag to Create Tables","slug":"using-the-div-tag-to-create-tables","categoryList":["technology","programming-web-design","css3"],"_links":{"self":"https://dummies-api.dummies.com/v2/articles/142904"}}]},"hasRelatedBookFromSearch":false,"relatedBook":{"bookId":0,"slug":null,"isbn":null,"categoryList":null,"amazon":null,"image":null,"title":null,"testBankPinActivationLink":null,"bookOutOfPrint":false,"authorsInfo":null,"authors":null,"_links":null},"collections":[],"articleAds":{"footerAd":"<div class=\"du-ad-region row\" id=\"article_page_adhesion_ad\"><div class=\"du-ad-unit col-md-12\" data-slot-id=\"article_page_adhesion_ad\" data-refreshed=\"false\" \r\n data-target = \"[{&quot;key&quot;:&quot;cat&quot;,&quot;values&quot;:[&quot;technology&quot;,&quot;programming-web-design&quot;,&quot;css3&quot;]},{&quot;key&quot;:&quot;isbn&quot;,&quot;values&quot;:[null]}]\" id=\"du-slot-63221ab2e9bc5\"></div></div>","rightAd":"<div class=\"du-ad-region row\" id=\"article_page_right_ad\"><div class=\"du-ad-unit col-md-12\" data-slot-id=\"article_page_right_ad\" data-refreshed=\"false\" \r\n data-target = \"[{&quot;key&quot;:&quot;cat&quot;,&quot;values&quot;:[&quot;technology&quot;,&quot;programming-web-design&quot;,&quot;css3&quot;]},{&quot;key&quot;:&quot;isbn&quot;,&quot;values&quot;:[null]}]\" id=\"du-slot-63221ab2ea432\"></div></div>"},"articleType":{"articleType":"Articles","articleList":null,"content":null,"videoInfo":{"videoId":null,"name":null,"accountId":null,"playerId":null,"thumbnailUrl":null,"description":null,"uploadDate":null}},"sponsorship":{"sponsorshipPage":false,"backgroundImage":{"src":null,"width":0,"height":0},"brandingLine":"","brandingLink":"","brandingLogo":{"src":null,"width":0,"height":0},"sponsorAd":"","sponsorEbookTitle":"","sponsorEbookLink":"","sponsorEbookImage":{"src":null,"width":0,"height":0}},"primaryLearningPath":"Advance","lifeExpectancy":null,"lifeExpectancySetFrom":null,"dummiesForKids":"no","sponsoredContent":"no","adInfo":"","adPairKey":[]},"status":"publish","visibility":"public","articleId":156489},{"headers":{"creationTime":"2016-03-26T13:11:53+00:00","modifiedTime":"2016-03-26T13:11:53+00:00","timestamp":"2022-09-14T18:04:50+00:00"},"data":{"breadcrumbs":[{"name":"Technology","_links":{"self":"https://dummies-api.dummies.com/v2/categories/33512"},"slug":"technology","categoryId":33512},{"name":"Programming & Web Design","_links":{"self":"https://dummies-api.dummies.com/v2/categories/33592"},"slug":"programming-web-design","categoryId":33592},{"name":"CSS3","_links":{"self":"https://dummies-api.dummies.com/v2/categories/34324"},"slug":"css3","categoryId":34324}],"title":"How to Create External Styles in CSS3","strippedTitle":"how to create external styles in css3","slug":"how-to-create-external-styles-in-css3","canonicalUrl":"","seo":{"metaDescription":"Most developers use external styles in CSS3 to reduce the amount of work required to maintain a site. A single .CSS file contains all of the styles for the site","noIndex":0,"noFollow":0},"content":"<p>Most developers use external styles in CSS3 to reduce the amount of work required to maintain a site. A single .CSS file contains all of the styles for the site, which means that changing a style site-wide is as simple as changing that one file (rather than each page). Because the change occurs in just one place, there isn’t any chance of missing one or more changes on individual pages.</p>\n<p>Creating and using an external style sheet isn’t much different from using an internal style sheet. The following example uses standard techniques to create an external style sheet:</p>\n<ol class=\"level-one\">\n <li><p class=\"first-para\">Create a new HTML5 file with your text editor.</p>\n </li>\n <li><p class=\"first-para\">Type the code for the HTML page.</p>\n<pre class=\"code\">&lt;!DOCTYPE html&gt;\n&lt;html&gt;\n&lt;head&gt;\n &lt;title&gt;A Simple Page&lt;/title&gt;\n&lt;/head&gt;\n&lt;body&gt;\n &lt;h1&gt;A Simple Heading&lt;/h1&gt;\n &lt;p&gt;Simple text to go with the heading.&lt;/p&gt;\n&lt;/body&gt;\n&lt;/html&gt;</pre>\n<p class=\"child-para\">Make sure you type the code precisely. What you should end up with is the same plain page — one without any styles.</p>\n </li>\n <li><p class=\"first-para\">Type the following code immediately after the <title> tag.</p>\n<pre class=\"code\">&lt;link rel=\"stylesheet\" href=\"ExternalCSS.CSS\" /&gt;</pre>\n<p class=\"child-para\">The <link> tag tells the browser to look for an external resource. In this case, the rel attribute says that it should look for a style sheet and the href attribute provides the name of that style sheet.</p>\n </li>\n <li><p class=\"first-para\">Save the HTML5 file to disk.</p>\n </li>\n <li><p class=\"first-para\">Create a new .CSS file with your text editor.</p>\n<p class=\"child-para\">Your editor may not support .CSS files. Any text file will do.</p>\n </li>\n <li><p class=\"first-para\">Type the following code in the .CSS file.</p>\n<pre class=\"code\">p\n{\n font-family: cursive;\n font-size: large;\n color: #0000ff;\n background-color: #ffff00;\n}\nh1\n{\n font-family: \"Times New Roman\",Georgia,serif;\n font-size: 40px;\n text-align: center;\n text-decoration: underline;\n color: #ff0000;\n background-color: #00ffff;\n}</pre>\n<p class=\"child-para\">This may be the same code that you used to create your internal file. The only difference is that it now resides in an external file.</p>\n </li>\n <li><p class=\"first-para\">Save the CSS file to disk as ExternalCSS.CSS.</p>\n<p class=\"child-para\">It’s absolutely essential that the name of the file precisely match the name found in the href attribute. Some platforms are case sensitive, so you must use the same case for the filename. For example, externalcss.css might be viewed as a different file from ExternalCSS.CSS.</p>\n </li>\n <li><p class=\"first-para\">Load the page in your browser.</p>\n<img src=\"https://www.dummies.com/wp-content/uploads/414625.image0.jpg\" width=\"460\" height=\"169\" alt=\"image0.jpg\"/>\n </li>\n</ol>","description":"<p>Most developers use external styles in CSS3 to reduce the amount of work required to maintain a site. A single .CSS file contains all of the styles for the site, which means that changing a style site-wide is as simple as changing that one file (rather than each page). Because the change occurs in just one place, there isn’t any chance of missing one or more changes on individual pages.</p>\n<p>Creating and using an external style sheet isn’t much different from using an internal style sheet. The following example uses standard techniques to create an external style sheet:</p>\n<ol class=\"level-one\">\n <li><p class=\"first-para\">Create a new HTML5 file with your text editor.</p>\n </li>\n <li><p class=\"first-para\">Type the code for the HTML page.</p>\n<pre class=\"code\">&lt;!DOCTYPE html&gt;\n&lt;html&gt;\n&lt;head&gt;\n &lt;title&gt;A Simple Page&lt;/title&gt;\n&lt;/head&gt;\n&lt;body&gt;\n &lt;h1&gt;A Simple Heading&lt;/h1&gt;\n &lt;p&gt;Simple text to go with the heading.&lt;/p&gt;\n&lt;/body&gt;\n&lt;/html&gt;</pre>\n<p class=\"child-para\">Make sure you type the code precisely. What you should end up with is the same plain page — one without any styles.</p>\n </li>\n <li><p class=\"first-para\">Type the following code immediately after the <title> tag.</p>\n<pre class=\"code\">&lt;link rel=\"stylesheet\" href=\"ExternalCSS.CSS\" /&gt;</pre>\n<p class=\"child-para\">The <link> tag tells the browser to look for an external resource. In this case, the rel attribute says that it should look for a style sheet and the href attribute provides the name of that style sheet.</p>\n </li>\n <li><p class=\"first-para\">Save the HTML5 file to disk.</p>\n </li>\n <li><p class=\"first-para\">Create a new .CSS file with your text editor.</p>\n<p class=\"child-para\">Your editor may not support .CSS files. Any text file will do.</p>\n </li>\n <li><p class=\"first-para\">Type the following code in the .CSS file.</p>\n<pre class=\"code\">p\n{\n font-family: cursive;\n font-size: large;\n color: #0000ff;\n background-color: #ffff00;\n}\nh1\n{\n font-family: \"Times New Roman\",Georgia,serif;\n font-size: 40px;\n text-align: center;\n text-decoration: underline;\n color: #ff0000;\n background-color: #00ffff;\n}</pre>\n<p class=\"child-para\">This may be the same code that you used to create your internal file. The only difference is that it now resides in an external file.</p>\n </li>\n <li><p class=\"first-para\">Save the CSS file to disk as ExternalCSS.CSS.</p>\n<p class=\"child-para\">It’s absolutely essential that the name of the file precisely match the name found in the href attribute. Some platforms are case sensitive, so you must use the same case for the filename. For example, externalcss.css might be viewed as a different file from ExternalCSS.CSS.</p>\n </li>\n <li><p class=\"first-para\">Load the page in your browser.</p>\n<img src=\"https://www.dummies.com/wp-content/uploads/414625.image0.jpg\" width=\"460\" height=\"169\" alt=\"image0.jpg\"/>\n </li>\n</ol>","blurb":"","authors":[{"authorId":9109,"name":"John Paul Mueller","slug":"john-paul-mueller","description":" <p><b>John Mueller</b> has produced 114 books and more than 600 articles on topics ranging from functional programming techniques to working with Amazon Web Services &#40;AWS&#41;. <b>Luca Massaron,</b> a Google Developer Expert &#40;GDE&#41;,??interprets big data and transforms it into smart data through simple and effective data mining and machine learning techniques. ","hasArticle":false,"_links":{"self":"https://dummies-api.dummies.com/v2/authors/9109"}}],"primaryCategoryTaxonomy":{"categoryId":34324,"title":"CSS3","slug":"css3","_links":{"self":"https://dummies-api.dummies.com/v2/categories/34324"}},"secondaryCategoryTaxonomy":{"categoryId":0,"title":null,"slug":null,"_links":null},"tertiaryCategoryTaxonomy":{"categoryId":0,"title":null,"slug":null,"_links":null},"trendingArticles":[{"articleId":192609,"title":"How to Pray the Rosary: A Comprehensive Guide","slug":"how-to-pray-the-rosary","categoryList":["body-mind-spirit","religion-spirituality","christianity","catholicism"],"_links":{"self":"/articles/192609"}},{"articleId":208741,"title":"Kabbalah For Dummies Cheat Sheet","slug":"kabbalah-for-dummies-cheat-sheet","categoryList":["body-mind-spirit","religion-spirituality","kabbalah"],"_links":{"self":"/articles/208741"}},{"articleId":230957,"title":"Nikon D3400 For Dummies Cheat Sheet","slug":"nikon-d3400-dummies-cheat-sheet","categoryList":["home-auto-hobbies","photography"],"_links":{"self":"/articles/230957"}},{"articleId":235851,"title":"Praying the Rosary and Meditating on the Mysteries","slug":"praying-rosary-meditating-mysteries","categoryList":["body-mind-spirit","religion-spirituality","christianity","catholicism"],"_links":{"self":"/articles/235851"}},{"articleId":284787,"title":"What Your Society Says About You","slug":"what-your-society-says-about-you","categoryList":["academics-the-arts","humanities"],"_links":{"self":"/articles/284787"}}],"inThisArticle":[],"relatedArticles":{"fromBook":[],"fromCategory":[{"articleId":156489,"title":"How to Detect the User’s Browser Type in CSS3","slug":"how-to-detect-the-users-browser-type-in-css3","categoryList":["technology","programming-web-design","css3"],"_links":{"self":"https://dummies-api.dummies.com/v2/articles/156489"}},{"articleId":156485,"title":"How to Use Multiple Styles Together with CSS3","slug":"how-to-use-multiple-styles-together-with-css3","categoryList":["technology","programming-web-design","css3"],"_links":{"self":"https://dummies-api.dummies.com/v2/articles/156485"}},{"articleId":142904,"title":"Using the Div Tag to Create Tables","slug":"using-the-div-tag-to-create-tables","categoryList":["technology","programming-web-design","css3"],"_links":{"self":"https://dummies-api.dummies.com/v2/articles/142904"}}]},"hasRelatedBookFromSearch":false,"relatedBook":{"bookId":0,"slug":null,"isbn":null,"categoryList":null,"amazon":null,"image":null,"title":null,"testBankPinActivationLink":null,"bookOutOfPrint":false,"authorsInfo":null,"authors":null,"_links":null},"collections":[],"articleAds":{"footerAd":"<div class=\"du-ad-region row\" id=\"article_page_adhesion_ad\"><div class=\"du-ad-unit col-md-12\" data-slot-id=\"article_page_adhesion_ad\" data-refreshed=\"false\" \r\n data-target = \"[{&quot;key&quot;:&quot;cat&quot;,&quot;values&quot;:[&quot;technology&quot;,&quot;programming-web-design&quot;,&quot;css3&quot;]},{&quot;key&quot;:&quot;isbn&quot;,&quot;values&quot;:[null]}]\" id=\"du-slot-632217c300a58\"></div></div>","rightAd":"<div class=\"du-ad-region row\" id=\"article_page_right_ad\"><div class=\"du-ad-unit col-md-12\" data-slot-id=\"article_page_right_ad\" data-refreshed=\"false\" \r\n data-target = \"[{&quot;key&quot;:&quot;cat&quot;,&quot;values&quot;:[&quot;technology&quot;,&quot;programming-web-design&quot;,&quot;css3&quot;]},{&quot;key&quot;:&quot;isbn&quot;,&quot;values&quot;:[null]}]\" id=\"du-slot-632217c300fe8\"></div></div>"},"articleType":{"articleType":"Articles","articleList":null,"content":null,"videoInfo":{"videoId":null,"name":null,"accountId":null,"playerId":null,"thumbnailUrl":null,"description":null,"uploadDate":null}},"sponsorship":{"sponsorshipPage":false,"backgroundImage":{"src":null,"width":0,"height":0},"brandingLine":"","brandingLink":"","brandingLogo":{"src":null,"width":0,"height":0},"sponsorAd":"","sponsorEbookTitle":"","sponsorEbookLink":"","sponsorEbookImage":{"src":null,"width":0,"height":0}},"primaryLearningPath":"Advance","lifeExpectancy":null,"lifeExpectancySetFrom":null,"dummiesForKids":"no","sponsoredContent":"no","adInfo":"","adPairKey":[]},"status":"publish","visibility":"public","articleId":156517},{"headers":{"creationTime":"2016-03-26T13:11:39+00:00","modifiedTime":"2016-03-26T13:11:39+00:00","timestamp":"2022-09-14T18:04:50+00:00"},"data":{"breadcrumbs":[{"name":"Technology","_links":{"self":"https://dummies-api.dummies.com/v2/categories/33512"},"slug":"technology","categoryId":33512},{"name":"Programming & Web Design","_links":{"self":"https://dummies-api.dummies.com/v2/categories/33592"},"slug":"programming-web-design","categoryId":33592},{"name":"CSS3","_links":{"self":"https://dummies-api.dummies.com/v2/categories/34324"},"slug":"css3","categoryId":34324}],"title":"How to Use Multiple Styles Together with CSS3","strippedTitle":"how to use multiple styles together with css3","slug":"how-to-use-multiple-styles-together-with-css3","canonicalUrl":"","seo":{"metaDescription":"Understanding the rules of inheritance in CSS3 helps you create interesting sites that require a minimum of maintenance. By following these rules, when maintena","noIndex":0,"noFollow":0},"content":"<p>Understanding the rules of inheritance in CSS3 helps you create interesting sites that require a minimum of maintenance. By following these rules, when maintenance is required, you normally have to make just one change, rather than changing hundreds of items individually. It pays to experiment, though, so you can understand the full effects of inheritance and the effects of using multiple styles together.</p>\n<ol class=\"level-one\">\n <li><p class=\"first-para\">Create a new HTML5 file with your text editor.</p>\n<p class=\"child-para\">Your editor may not support HTML5 files. Any text file will do.</p>\n </li>\n <li><p class=\"first-para\">Type the following code for the HTML page.</p>\n<pre class=\"code\">&lt;!DOCTYPE html&gt;\n&lt;html&gt;\n&lt;head&gt;\n &lt;title&gt;Inheritance Example&lt;/title&gt;\n &lt;style&gt;\n p\n {\n font-family: Arial, Helvetica, sans-serif;\n color: Blue;\n background-color: Yellow;\n margin: 0;\n font-style: italic;\n font-size: medium;\n }\n div p\n {\n font-style: italic;\n font-size: larger;\n }\n &lt;/style&gt;\n&lt;/head&gt;\n&lt;body&gt;\n &lt;h1&gt;An Example of CSS Inheritance&lt;/h1&gt;\n &lt;p&gt;A paragraph outside a\n &lt;span style=\"font-family: monospace\"&gt;\n &lt;div&gt;&lt;/span&gt;.&lt;/p&gt;\n &lt;div id=\"Container\"\n style=\"text-align: left;\"&gt;\n &lt;p&gt;A paragraph inside a container.&lt;/p&gt;\n &lt;/div&gt;\n&lt;/body&gt;\n&lt;/html&gt;</pre>\n<p class=\"child-para\">This page contains a number of inline styles, which always have the highest inheritance precedence. For example, the <span> provides a font-family of monospace for the <div> tag part of the sentence. You could accomplish the same thing by assigning the <span> a class attribute for code, but this example uses the inline style instead.</p>\n<p class=\"child-para\">The <div> uses an inline style to set the text-align style to left. Because the default style sets the alignment to left, you won’t see any difference. However, if another style change modifies the text alignment, this style will take effect and prevent movement of this paragraph.</p>\n<p class=\"child-para\">The internal style modifications all appear within the <style> tag in the <head> element. The first style sets the general characteristics for a <p> tag. Notice that the style specifically sets the font-style to italic and the font-size to medium.</p>\n<p class=\"child-para\">The second style is more specific. It sets the characteristics for <p> tags that appear as a child of a <div>. Consequently, inheritance rules say that this style will take precedence when the rules of inheritance are met, which means the font-style and font-size styles will be different in this case.</p>\n </li>\n <li><p class=\"first-para\">Save the file as Inheritance.HTML.</p>\n </li>\n <li><p class=\"first-para\">Load the Inheritance example into your browser.</p>\n<p class=\"child-para\">You see the role that inheritance and cascading styles play.</p>\n<img src=\"https://www.dummies.com/wp-content/uploads/414686.image0.jpg\" width=\"535\" height=\"183\" alt=\"image0.jpg\"/>\n </li>\n <li><p class=\"first-para\">Create a new CSS file with your text editor.</p>\n<p class=\"child-para\">Your editor may not support CSS files. Any text file will do.</p>\n </li>\n <li><p class=\"first-para\">Type the following CSS style information.</p>\n<pre class=\"code\">body\n{\n text-align: center;\n color: DarkRed;\n background-color: Khaki;\n border: inset;\n border-color: Green;\n}\nh1\n{\n border: outset;\n border-color: Brown;\n}\np\n{\n text-decoration: underline;\n font-family: \"Times New Roman\", Times, serif;\n font-style: oblique;\n font-size: xx-large;\n}</pre>\n<p class=\"child-para\">The <body> tag appears as the topmost object in a page, so the changes noted in the body style should affect everything not specifically overridden later. In this case, the example changes the text alignment to center and places a dark red border around any content. The background color is also changed. Finally, the style adds a green border around every object.</p>\n<p class=\"child-para\">The h1 style overrides any body styles. In this case, that means modifying the border styles.</p>\n<p class=\"child-para\">The p style also overrides any body styles. However, there aren’t any properties that are the same in this case, so the p styles enhance the styles inherited from the body style.</p>\n </li>\n <li><p class=\"first-para\">Save the file as Inheritance.CSS.</p>\n </li>\n <li><p class=\"first-para\">Add the following code to the <head> area of the HTML file.</p>\n<pre class=\"code\">&lt;link rel=\"stylesheet\" href=\"Inheritance.CSS\" /&gt;</pre>\n<p class=\"child-para\">This code creates the link between the HTML file and the CSS file.</p>\n </li>\n <li><p class=\"first-para\">Save the HTML file and reload the page.</p>\n<img src=\"https://www.dummies.com/wp-content/uploads/414687.image1.jpg\" width=\"535\" height=\"182\" alt=\"image1.jpg\"/>\n<p class=\"child-para\">Notice that all the expected changes are in place. For example, the text is centered, except for the one paragraph that has an inline style overriding the centered text. The heading text is now in dark red — the paragraph text overrides that color selection, so it remains blue. Even though there is an external p style for the size of the text, the internal style overrides it.</p>\n<p class=\"child-para\">You should notice something else about the example. The body contains an inset border of the correct color and the heading contains an outset border of the correct color, because it has overridden the default.</p>\n<p class=\"child-para\">However, the paragraphs have no border. At one time, <body> tag changes affected the entire document and some of them still do. However, other changes affect only the body and not other block elements. Block elements don’t inherit some settings from the body style.</p>\n </li>\n <li><p class=\"first-para\">Delete the h1 style from the Inheritance.CSS style sheet.</p>\n<p class=\"child-para\">You can also comment out the h1 style by adding the starting (/*) and ending (*/) comment symbols to it like this:</p>\n<pre class=\"code\">/* Commented out to show block settings.\nh1\n{\n border: outset;\n border-color: Brown;\n}\n*/</pre>\n </li>\n <li><p class=\"first-para\">Save the CSS file and reload the page.</p>\n<img src=\"https://www.dummies.com/wp-content/uploads/414688.image2.jpg\" width=\"535\" height=\"184\" alt=\"image2.jpg\"/>\n<p class=\"child-para\">Notice that the heading now lacks a border. It turns out that the heading wasn’t overriding the body-level border — it was adding a new border. Never assume that a body style will carry through to other block-level styles — some settings simply don’t. When you find that your page doesn’t look as you expected it to look, try configuring the setting at a lower block level.</p>\n<p class=\"child-para\">You may also see some style sheets that access the html style, which affects the <html> tag that contains the <body> tag. It’s true: You can work with the html style to achieve some effects.</p>\n </li>\n <li><p class=\"first-para\">Add the html style shown here to the Inheritance.CSS style sheet.</p>\n<pre class=\"code\">html\n{\n border: outset;\n border-color: Green;\n background-color: White;\n}</pre>\n </li>\n <li><p class=\"first-para\">Save the CSS file and reload the page.</p>\n<img src=\"https://www.dummies.com/wp-content/uploads/414689.image3.jpg\" width=\"535\" height=\"182\" alt=\"image3.jpg\"/>\n<p class=\"child-para\">You rarely have to rely on the html style because it simply isn’t necessary. The html block is a level above the body block, as shown by this example. The html block doesn’t give you access to anything that the body block can’t change in most cases, except for special effects like the one shown here.</p>\n </li>\n</ol>","description":"<p>Understanding the rules of inheritance in CSS3 helps you create interesting sites that require a minimum of maintenance. By following these rules, when maintenance is required, you normally have to make just one change, rather than changing hundreds of items individually. It pays to experiment, though, so you can understand the full effects of inheritance and the effects of using multiple styles together.</p>\n<ol class=\"level-one\">\n <li><p class=\"first-para\">Create a new HTML5 file with your text editor.</p>\n<p class=\"child-para\">Your editor may not support HTML5 files. Any text file will do.</p>\n </li>\n <li><p class=\"first-para\">Type the following code for the HTML page.</p>\n<pre class=\"code\">&lt;!DOCTYPE html&gt;\n&lt;html&gt;\n&lt;head&gt;\n &lt;title&gt;Inheritance Example&lt;/title&gt;\n &lt;style&gt;\n p\n {\n font-family: Arial, Helvetica, sans-serif;\n color: Blue;\n background-color: Yellow;\n margin: 0;\n font-style: italic;\n font-size: medium;\n }\n div p\n {\n font-style: italic;\n font-size: larger;\n }\n &lt;/style&gt;\n&lt;/head&gt;\n&lt;body&gt;\n &lt;h1&gt;An Example of CSS Inheritance&lt;/h1&gt;\n &lt;p&gt;A paragraph outside a\n &lt;span style=\"font-family: monospace\"&gt;\n &lt;div&gt;&lt;/span&gt;.&lt;/p&gt;\n &lt;div id=\"Container\"\n style=\"text-align: left;\"&gt;\n &lt;p&gt;A paragraph inside a container.&lt;/p&gt;\n &lt;/div&gt;\n&lt;/body&gt;\n&lt;/html&gt;</pre>\n<p class=\"child-para\">This page contains a number of inline styles, which always have the highest inheritance precedence. For example, the <span> provides a font-family of monospace for the <div> tag part of the sentence. You could accomplish the same thing by assigning the <span> a class attribute for code, but this example uses the inline style instead.</p>\n<p class=\"child-para\">The <div> uses an inline style to set the text-align style to left. Because the default style sets the alignment to left, you won’t see any difference. However, if another style change modifies the text alignment, this style will take effect and prevent movement of this paragraph.</p>\n<p class=\"child-para\">The internal style modifications all appear within the <style> tag in the <head> element. The first style sets the general characteristics for a <p> tag. Notice that the style specifically sets the font-style to italic and the font-size to medium.</p>\n<p class=\"child-para\">The second style is more specific. It sets the characteristics for <p> tags that appear as a child of a <div>. Consequently, inheritance rules say that this style will take precedence when the rules of inheritance are met, which means the font-style and font-size styles will be different in this case.</p>\n </li>\n <li><p class=\"first-para\">Save the file as Inheritance.HTML.</p>\n </li>\n <li><p class=\"first-para\">Load the Inheritance example into your browser.</p>\n<p class=\"child-para\">You see the role that inheritance and cascading styles play.</p>\n<img src=\"https://www.dummies.com/wp-content/uploads/414686.image0.jpg\" width=\"535\" height=\"183\" alt=\"image0.jpg\"/>\n </li>\n <li><p class=\"first-para\">Create a new CSS file with your text editor.</p>\n<p class=\"child-para\">Your editor may not support CSS files. Any text file will do.</p>\n </li>\n <li><p class=\"first-para\">Type the following CSS style information.</p>\n<pre class=\"code\">body\n{\n text-align: center;\n color: DarkRed;\n background-color: Khaki;\n border: inset;\n border-color: Green;\n}\nh1\n{\n border: outset;\n border-color: Brown;\n}\np\n{\n text-decoration: underline;\n font-family: \"Times New Roman\", Times, serif;\n font-style: oblique;\n font-size: xx-large;\n}</pre>\n<p class=\"child-para\">The <body> tag appears as the topmost object in a page, so the changes noted in the body style should affect everything not specifically overridden later. In this case, the example changes the text alignment to center and places a dark red border around any content. The background color is also changed. Finally, the style adds a green border around every object.</p>\n<p class=\"child-para\">The h1 style overrides any body styles. In this case, that means modifying the border styles.</p>\n<p class=\"child-para\">The p style also overrides any body styles. However, there aren’t any properties that are the same in this case, so the p styles enhance the styles inherited from the body style.</p>\n </li>\n <li><p class=\"first-para\">Save the file as Inheritance.CSS.</p>\n </li>\n <li><p class=\"first-para\">Add the following code to the <head> area of the HTML file.</p>\n<pre class=\"code\">&lt;link rel=\"stylesheet\" href=\"Inheritance.CSS\" /&gt;</pre>\n<p class=\"child-para\">This code creates the link between the HTML file and the CSS file.</p>\n </li>\n <li><p class=\"first-para\">Save the HTML file and reload the page.</p>\n<img src=\"https://www.dummies.com/wp-content/uploads/414687.image1.jpg\" width=\"535\" height=\"182\" alt=\"image1.jpg\"/>\n<p class=\"child-para\">Notice that all the expected changes are in place. For example, the text is centered, except for the one paragraph that has an inline style overriding the centered text. The heading text is now in dark red — the paragraph text overrides that color selection, so it remains blue. Even though there is an external p style for the size of the text, the internal style overrides it.</p>\n<p class=\"child-para\">You should notice something else about the example. The body contains an inset border of the correct color and the heading contains an outset border of the correct color, because it has overridden the default.</p>\n<p class=\"child-para\">However, the paragraphs have no border. At one time, <body> tag changes affected the entire document and some of them still do. However, other changes affect only the body and not other block elements. Block elements don’t inherit some settings from the body style.</p>\n </li>\n <li><p class=\"first-para\">Delete the h1 style from the Inheritance.CSS style sheet.</p>\n<p class=\"child-para\">You can also comment out the h1 style by adding the starting (/*) and ending (*/) comment symbols to it like this:</p>\n<pre class=\"code\">/* Commented out to show block settings.\nh1\n{\n border: outset;\n border-color: Brown;\n}\n*/</pre>\n </li>\n <li><p class=\"first-para\">Save the CSS file and reload the page.</p>\n<img src=\"https://www.dummies.com/wp-content/uploads/414688.image2.jpg\" width=\"535\" height=\"184\" alt=\"image2.jpg\"/>\n<p class=\"child-para\">Notice that the heading now lacks a border. It turns out that the heading wasn’t overriding the body-level border — it was adding a new border. Never assume that a body style will carry through to other block-level styles — some settings simply don’t. When you find that your page doesn’t look as you expected it to look, try configuring the setting at a lower block level.</p>\n<p class=\"child-para\">You may also see some style sheets that access the html style, which affects the <html> tag that contains the <body> tag. It’s true: You can work with the html style to achieve some effects.</p>\n </li>\n <li><p class=\"first-para\">Add the html style shown here to the Inheritance.CSS style sheet.</p>\n<pre class=\"code\">html\n{\n border: outset;\n border-color: Green;\n background-color: White;\n}</pre>\n </li>\n <li><p class=\"first-para\">Save the CSS file and reload the page.</p>\n<img src=\"https://www.dummies.com/wp-content/uploads/414689.image3.jpg\" width=\"535\" height=\"182\" alt=\"image3.jpg\"/>\n<p class=\"child-para\">You rarely have to rely on the html style because it simply isn’t necessary. The html block is a level above the body block, as shown by this example. The html block doesn’t give you access to anything that the body block can’t change in most cases, except for special effects like the one shown here.</p>\n </li>\n</ol>","blurb":"","authors":[{"authorId":9109,"name":"John Paul Mueller","slug":"john-paul-mueller","description":" <p><b>John Mueller</b> has produced 114 books and more than 600 articles on topics ranging from functional programming techniques to working with Amazon Web Services &#40;AWS&#41;. <b>Luca Massaron,</b> a Google Developer Expert &#40;GDE&#41;,??interprets big data and transforms it into smart data through simple and effective data mining and machine learning techniques. ","hasArticle":false,"_links":{"self":"https://dummies-api.dummies.com/v2/authors/9109"}}],"primaryCategoryTaxonomy":{"categoryId":34324,"title":"CSS3","slug":"css3","_links":{"self":"https://dummies-api.dummies.com/v2/categories/34324"}},"secondaryCategoryTaxonomy":{"categoryId":0,"title":null,"slug":null,"_links":null},"tertiaryCategoryTaxonomy":{"categoryId":0,"title":null,"slug":null,"_links":null},"trendingArticles":[{"articleId":192609,"title":"How to Pray the Rosary: A Comprehensive Guide","slug":"how-to-pray-the-rosary","categoryList":["body-mind-spirit","religion-spirituality","christianity","catholicism"],"_links":{"self":"/articles/192609"}},{"articleId":208741,"title":"Kabbalah For Dummies Cheat Sheet","slug":"kabbalah-for-dummies-cheat-sheet","categoryList":["body-mind-spirit","religion-spirituality","kabbalah"],"_links":{"self":"/articles/208741"}},{"articleId":230957,"title":"Nikon D3400 For Dummies Cheat Sheet","slug":"nikon-d3400-dummies-cheat-sheet","categoryList":["home-auto-hobbies","photography"],"_links":{"self":"/articles/230957"}},{"articleId":235851,"title":"Praying the Rosary and Meditating on the Mysteries","slug":"praying-rosary-meditating-mysteries","categoryList":["body-mind-spirit","religion-spirituality","christianity","catholicism"],"_links":{"self":"/articles/235851"}},{"articleId":284787,"title":"What Your Society Says About You","slug":"what-your-society-says-about-you","categoryList":["academics-the-arts","humanities"],"_links":{"self":"/articles/284787"}}],"inThisArticle":[],"relatedArticles":{"fromBook":[],"fromCategory":[{"articleId":156517,"title":"How to Create External Styles in CSS3","slug":"how-to-create-external-styles-in-css3","categoryList":["technology","programming-web-design","css3"],"_links":{"self":"https://dummies-api.dummies.com/v2/articles/156517"}},{"articleId":156489,"title":"How to Detect the User’s Browser Type in CSS3","slug":"how-to-detect-the-users-browser-type-in-css3","categoryList":["technology","programming-web-design","css3"],"_links":{"self":"https://dummies-api.dummies.com/v2/articles/156489"}},{"articleId":142904,"title":"Using the Div Tag to Create Tables","slug":"using-the-div-tag-to-create-tables","categoryList":["technology","programming-web-design","css3"],"_links":{"self":"https://dummies-api.dummies.com/v2/articles/142904"}}]},"hasRelatedBookFromSearch":false,"relatedBook":{"bookId":0,"slug":null,"isbn":null,"categoryList":null,"amazon":null,"image":null,"title":null,"testBankPinActivationLink":null,"bookOutOfPrint":false,"authorsInfo":null,"authors":null,"_links":null},"collections":[],"articleAds":{"footerAd":"<div class=\"du-ad-region row\" id=\"article_page_adhesion_ad\"><div class=\"du-ad-unit col-md-12\" data-slot-id=\"article_page_adhesion_ad\" data-refreshed=\"false\" \r\n data-target = \"[{&quot;key&quot;:&quot;cat&quot;,&quot;values&quot;:[&quot;technology&quot;,&quot;programming-web-design&quot;,&quot;css3&quot;]},{&quot;key&quot;:&quot;isbn&quot;,&quot;values&quot;:[null]}]\" id=\"du-slot-632217c2e1ae7\"></div></div>","rightAd":"<div class=\"du-ad-region row\" id=\"article_page_right_ad\"><div class=\"du-ad-unit col-md-12\" data-slot-id=\"article_page_right_ad\" data-refreshed=\"false\" \r\n data-target = \"[{&quot;key&quot;:&quot;cat&quot;,&quot;values&quot;:[&quot;technology&quot;,&quot;programming-web-design&quot;,&quot;css3&quot;]},{&quot;key&quot;:&quot;isbn&quot;,&quot;values&quot;:[null]}]\" id=\"du-slot-632217c2ef5a3\"></div></div>"},"articleType":{"articleType":"Articles","articleList":null,"content":null,"videoInfo":{"videoId":null,"name":null,"accountId":null,"playerId":null,"thumbnailUrl":null,"description":null,"uploadDate":null}},"sponsorship":{"sponsorshipPage":false,"backgroundImage":{"src":null,"width":0,"height":0},"brandingLine":"","brandingLink":"","brandingLogo":{"src":null,"width":0,"height":0},"sponsorAd":"","sponsorEbookTitle":"","sponsorEbookLink":"","sponsorEbookImage":{"src":null,"width":0,"height":0}},"primaryLearningPath":"Advance","lifeExpectancy":null,"lifeExpectancySetFrom":null,"dummiesForKids":"no","sponsoredContent":"no","adInfo":"","adPairKey":[]},"status":"publish","visibility":"public","articleId":156485},{"headers":{"creationTime":"2016-03-26T07:41:36+00:00","modifiedTime":"2016-03-26T07:41:36+00:00","timestamp":"2022-09-14T17:51:22+00:00"},"data":{"breadcrumbs":[{"name":"Technology","_links":{"self":"https://dummies-api.dummies.com/v2/categories/33512"},"slug":"technology","categoryId":33512},{"name":"Programming & Web Design","_links":{"self":"https://dummies-api.dummies.com/v2/categories/33592"},"slug":"programming-web-design","categoryId":33592},{"name":"CSS3","_links":{"self":"https://dummies-api.dummies.com/v2/categories/34324"},"slug":"css3","categoryId":34324}],"title":"Using the Div Tag to Create Tables","strippedTitle":"using the div tag to create tables","slug":"using-the-div-tag-to-create-tables","canonicalUrl":"","seo":{"metaDescription":"Creating tables can be error prone and difficult using the older HTML tags. In addition, they prove inflexible at times. It’s possible to create tables using an","noIndex":0,"noFollow":0},"content":"<p>Creating tables can be error prone and difficult using the older HTML tags. In addition, they prove inflexible at times. It’s possible to create tables using another technique. All you need is a series of cascading <span class=\"code\"><div></span> tags to perform the task.</p>\n<div class=\"imageBlock\" style=\"width:500px;\"><img src=\"https://www.dummies.com/wp-content/uploads/479693.image0.jpg\" height=\"397\" alt=\"[Credit: ©iStockphoto.com/Anton Cherstvenkov]\" width=\"500\"/><div class=\"imageCredit\">Credit: ©iStockphoto.com/Anton Cherstvenkov</div></div>\n<p>Many developers have used tables for all sorts of tasks in the past. Of course, there is the use of tables to display data. However, tabular arrangements are also useful for creating forms to ensure the various elements align in a predictable manner. This second use of tables is problematic because it confuses some software such as screen readers. The problem becomes one of defining a well-organized page without creating problems for the people viewing it.</p>\n<p>Using <span class=\"code\"><div></span> tags to create a table makes it possible for viewers to see a table or a logical arrangement of controls with equal ease. This technique also has the benefit of not confusing screen readers and other software.</p>\n<p>Defining the HTML for a <span class=\"code\"><div></span> table looks somewhat like creating a table using the older tags, except you don’t have to worry about odd arrangements of arcane tags to do it. Here is the HTML for a table that contains a title, headings, and two rows of content.</p>\n<pre class=\"code\">&lt;div class=\"Table\"&gt;\n &lt;div class=\"Title\"&gt;\n &lt;p&gt;This is a Table&lt;/p&gt;\n &lt;/div&gt;\n &lt;div class=\"Heading\"&gt;\n &lt;div class=\"Cell\"&gt;\n &lt;p&gt;Heading 1&lt;/p&gt;\n &lt;/div&gt;\n &lt;div class=\"Cell\"&gt;\n &lt;p&gt;Heading 2&lt;/p&gt;\n &lt;/div&gt;\n &lt;div class=\"Cell\"&gt;\n &lt;p&gt;Heading 3&lt;/p&gt;\n &lt;/div&gt;\n &lt;/div&gt;\n &lt;div class=\"Row\"&gt;\n &lt;div class=\"Cell\"&gt;\n &lt;p&gt;Row 1 Column 1&lt;/p&gt;\n &lt;/div&gt;\n &lt;div class=\"Cell\"&gt;\n &lt;p&gt;Row 1 Column 2&lt;/p&gt;\n &lt;/div&gt;\n &lt;div class=\"Cell\"&gt;\n &lt;p&gt;Row 1 Column 3&lt;/p&gt;\n &lt;/div&gt;\n &lt;/div&gt;\n &lt;div class=\"Row\"&gt;\n &lt;div class=\"Cell\"&gt;\n &lt;p&gt;Row 2 Column 1&lt;/p&gt;\n &lt;/div&gt;\n &lt;div class=\"Cell\"&gt;\n &lt;p&gt;Row 2 Column 2&lt;/p&gt;\n &lt;/div&gt;\n &lt;div class=\"Cell\"&gt;\n &lt;p&gt;Row 2 Column 3&lt;/p&gt;\n &lt;/div&gt;\n &lt;/div&gt;\n&lt;/div&gt;</pre>\n<p>Notice that each <span class=\"code\"><div></span> level is defined using an easily recognized name, such as Table, Title, Heading, Row, and Cell. Using this naming method makes it a lot easier to figure out what each level of the table is supposed to do. You can find many different alternatives to this approach online, but this basic approach will serve you well.</p>\n<p>The CSS for this table uses a few special properties and a little clever formatting. Here is the CSS used to make this example functional.</p>\n<pre class=\"code\">&lt;style type=\"text/css\"&gt;\n .Table\n {\n display: table;\n }\n .Title\n {\n display: table-caption;\n text-align: center;\n font-weight: bold;\n font-size: larger;\n }\n .Heading\n {\n display: table-row;\n font-weight: bold;\n text-align: center;\n }\n .Row\n {\n display: table-row;\n }\n .Cell\n {\n display: table-cell;\n border: solid;\n border-width: thin;\n padding-left: 5px;\n padding-right: 5px;\n }\n&lt;/style&gt;</pre>\n<p>Notice the use of the display property. This is the crucial property for your table because it tells the browser how to display a particular element. Otherwise, there isn’t anything strange of out of the normal about these styles. You define text attributes that help viewers differentiate between various table elements. Cells are separated from each other using a simple border. The following figure shows you how the table will appear when you view it in a browser.</p>\n<img src=\"https://www.dummies.com/wp-content/uploads/479694.image1.png\" height=\"422\" alt=\"image1.png\" width=\"535\"/>","description":"<p>Creating tables can be error prone and difficult using the older HTML tags. In addition, they prove inflexible at times. It’s possible to create tables using another technique. All you need is a series of cascading <span class=\"code\"><div></span> tags to perform the task.</p>\n<div class=\"imageBlock\" style=\"width:500px;\"><img src=\"https://www.dummies.com/wp-content/uploads/479693.image0.jpg\" height=\"397\" alt=\"[Credit: ©iStockphoto.com/Anton Cherstvenkov]\" width=\"500\"/><div class=\"imageCredit\">Credit: ©iStockphoto.com/Anton Cherstvenkov</div></div>\n<p>Many developers have used tables for all sorts of tasks in the past. Of course, there is the use of tables to display data. However, tabular arrangements are also useful for creating forms to ensure the various elements align in a predictable manner. This second use of tables is problematic because it confuses some software such as screen readers. The problem becomes one of defining a well-organized page without creating problems for the people viewing it.</p>\n<p>Using <span class=\"code\"><div></span> tags to create a table makes it possible for viewers to see a table or a logical arrangement of controls with equal ease. This technique also has the benefit of not confusing screen readers and other software.</p>\n<p>Defining the HTML for a <span class=\"code\"><div></span> table looks somewhat like creating a table using the older tags, except you don’t have to worry about odd arrangements of arcane tags to do it. Here is the HTML for a table that contains a title, headings, and two rows of content.</p>\n<pre class=\"code\">&lt;div class=\"Table\"&gt;\n &lt;div class=\"Title\"&gt;\n &lt;p&gt;This is a Table&lt;/p&gt;\n &lt;/div&gt;\n &lt;div class=\"Heading\"&gt;\n &lt;div class=\"Cell\"&gt;\n &lt;p&gt;Heading 1&lt;/p&gt;\n &lt;/div&gt;\n &lt;div class=\"Cell\"&gt;\n &lt;p&gt;Heading 2&lt;/p&gt;\n &lt;/div&gt;\n &lt;div class=\"Cell\"&gt;\n &lt;p&gt;Heading 3&lt;/p&gt;\n &lt;/div&gt;\n &lt;/div&gt;\n &lt;div class=\"Row\"&gt;\n &lt;div class=\"Cell\"&gt;\n &lt;p&gt;Row 1 Column 1&lt;/p&gt;\n &lt;/div&gt;\n &lt;div class=\"Cell\"&gt;\n &lt;p&gt;Row 1 Column 2&lt;/p&gt;\n &lt;/div&gt;\n &lt;div class=\"Cell\"&gt;\n &lt;p&gt;Row 1 Column 3&lt;/p&gt;\n &lt;/div&gt;\n &lt;/div&gt;\n &lt;div class=\"Row\"&gt;\n &lt;div class=\"Cell\"&gt;\n &lt;p&gt;Row 2 Column 1&lt;/p&gt;\n &lt;/div&gt;\n &lt;div class=\"Cell\"&gt;\n &lt;p&gt;Row 2 Column 2&lt;/p&gt;\n &lt;/div&gt;\n &lt;div class=\"Cell\"&gt;\n &lt;p&gt;Row 2 Column 3&lt;/p&gt;\n &lt;/div&gt;\n &lt;/div&gt;\n&lt;/div&gt;</pre>\n<p>Notice that each <span class=\"code\"><div></span> level is defined using an easily recognized name, such as Table, Title, Heading, Row, and Cell. Using this naming method makes it a lot easier to figure out what each level of the table is supposed to do. You can find many different alternatives to this approach online, but this basic approach will serve you well.</p>\n<p>The CSS for this table uses a few special properties and a little clever formatting. Here is the CSS used to make this example functional.</p>\n<pre class=\"code\">&lt;style type=\"text/css\"&gt;\n .Table\n {\n display: table;\n }\n .Title\n {\n display: table-caption;\n text-align: center;\n font-weight: bold;\n font-size: larger;\n }\n .Heading\n {\n display: table-row;\n font-weight: bold;\n text-align: center;\n }\n .Row\n {\n display: table-row;\n }\n .Cell\n {\n display: table-cell;\n border: solid;\n border-width: thin;\n padding-left: 5px;\n padding-right: 5px;\n }\n&lt;/style&gt;</pre>\n<p>Notice the use of the display property. This is the crucial property for your table because it tells the browser how to display a particular element. Otherwise, there isn’t anything strange of out of the normal about these styles. You define text attributes that help viewers differentiate between various table elements. Cells are separated from each other using a simple border. The following figure shows you how the table will appear when you view it in a browser.</p>\n<img src=\"https://www.dummies.com/wp-content/uploads/479694.image1.png\" height=\"422\" alt=\"image1.png\" width=\"535\"/>","blurb":"","authors":[{"authorId":9109,"name":"John Paul Mueller","slug":"john-paul-mueller","description":" <p><b>John Mueller</b> has produced 114 books and more than 600 articles on topics ranging from functional programming techniques to working with Amazon Web Services &#40;AWS&#41;. <b>Luca Massaron,</b> a Google Developer Expert &#40;GDE&#41;,??interprets big data and transforms it into smart data through simple and effective data mining and machine learning techniques. ","hasArticle":false,"_links":{"self":"https://dummies-api.dummies.com/v2/authors/9109"}}],"primaryCategoryTaxonomy":{"categoryId":34324,"title":"CSS3","slug":"css3","_links":{"self":"https://dummies-api.dummies.com/v2/categories/34324"}},"secondaryCategoryTaxonomy":{"categoryId":0,"title":null,"slug":null,"_links":null},"tertiaryCategoryTaxonomy":{"categoryId":0,"title":null,"slug":null,"_links":null},"trendingArticles":[{"articleId":192609,"title":"How to Pray the Rosary: A Comprehensive Guide","slug":"how-to-pray-the-rosary","categoryList":["body-mind-spirit","religion-spirituality","christianity","catholicism"],"_links":{"self":"/articles/192609"}},{"articleId":208741,"title":"Kabbalah For Dummies Cheat Sheet","slug":"kabbalah-for-dummies-cheat-sheet","categoryList":["body-mind-spirit","religion-spirituality","kabbalah"],"_links":{"self":"/articles/208741"}},{"articleId":230957,"title":"Nikon D3400 For Dummies Cheat Sheet","slug":"nikon-d3400-dummies-cheat-sheet","categoryList":["home-auto-hobbies","photography"],"_links":{"self":"/articles/230957"}},{"articleId":235851,"title":"Praying the Rosary and Meditating on the Mysteries","slug":"praying-rosary-meditating-mysteries","categoryList":["body-mind-spirit","religion-spirituality","christianity","catholicism"],"_links":{"self":"/articles/235851"}},{"articleId":284787,"title":"What Your Society Says About You","slug":"what-your-society-says-about-you","categoryList":["academics-the-arts","humanities"],"_links":{"self":"/articles/284787"}}],"inThisArticle":[],"relatedArticles":{"fromBook":[],"fromCategory":[{"articleId":156517,"title":"How to Create External Styles in CSS3","slug":"how-to-create-external-styles-in-css3","categoryList":["technology","programming-web-design","css3"],"_links":{"self":"https://dummies-api.dummies.com/v2/articles/156517"}},{"articleId":156489,"title":"How to Detect the User’s Browser Type in CSS3","slug":"how-to-detect-the-users-browser-type-in-css3","categoryList":["technology","programming-web-design","css3"],"_links":{"self":"https://dummies-api.dummies.com/v2/articles/156489"}},{"articleId":156485,"title":"How to Use Multiple Styles Together with CSS3","slug":"how-to-use-multiple-styles-together-with-css3","categoryList":["technology","programming-web-design","css3"],"_links":{"self":"https://dummies-api.dummies.com/v2/articles/156485"}}]},"hasRelatedBookFromSearch":false,"relatedBook":{"bookId":0,"slug":null,"isbn":null,"categoryList":null,"amazon":null,"image":null,"title":null,"testBankPinActivationLink":null,"bookOutOfPrint":false,"authorsInfo":null,"authors":null,"_links":null},"collections":[],"articleAds":{"footerAd":"<div class=\"du-ad-region row\" id=\"article_page_adhesion_ad\"><div class=\"du-ad-unit col-md-12\" data-slot-id=\"article_page_adhesion_ad\" data-refreshed=\"false\" \r\n data-target = \"[{&quot;key&quot;:&quot;cat&quot;,&quot;values&quot;:[&quot;technology&quot;,&quot;programming-web-design&quot;,&quot;css3&quot;]},{&quot;key&quot;:&quot;isbn&quot;,&quot;values&quot;:[null]}]\" id=\"du-slot-6322149b011d3\"></div></div>","rightAd":"<div class=\"du-ad-region row\" id=\"article_page_right_ad\"><div class=\"du-ad-unit col-md-12\" data-slot-id=\"article_page_right_ad\" data-refreshed=\"false\" \r\n data-target = \"[{&quot;key&quot;:&quot;cat&quot;,&quot;values&quot;:[&quot;technology&quot;,&quot;programming-web-design&quot;,&quot;css3&quot;]},{&quot;key&quot;:&quot;isbn&quot;,&quot;values&quot;:[null]}]\" id=\"du-slot-6322149b0176c\"></div></div>"},"articleType":{"articleType":"Articles","articleList":null,"content":null,"videoInfo":{"videoId":null,"name":null,"accountId":null,"playerId":null,"thumbnailUrl":null,"description":null,"uploadDate":null}},"sponsorship":{"sponsorshipPage":false,"backgroundImage":{"src":null,"width":0,"height":0},"brandingLine":"","brandingLink":"","brandingLogo":{"src":null,"width":0,"height":0},"sponsorAd":"","sponsorEbookTitle":"","sponsorEbookLink":"","sponsorEbookImage":{"src":null,"width":0,"height":0}},"primaryLearningPath":"Advance","lifeExpectancy":null,"lifeExpectancySetFrom":null,"dummiesForKids":"no","sponsoredContent":"no","adInfo":"","adPairKey":[]},"status":"publish","visibility":"public","articleId":142904}],"_links":{"self":{"self":"https://dummies-api.dummies.com/v2/categories/34324/categoryArticles?sortField=time&sortOrder=1&size=10&offset=0"}}},"objectTitle":"","status":"success","pageType":"article-category","objectId":"34324","page":1,"sortField":"time","sortOrder":1,"categoriesIds":[],"articleTypes":[],"filterData":{"categoriesFilter":[{"itemId":0,"itemName":"All Categories","count":4}],"articleTypeFilter":[{"articleType":"All Types","count":4},{"articleType":"Articles","count":4}]},"filterDataLoadedStatus":"success","pageSize":10},"adsState":{"pageScripts":{"headers":{"timestamp":"2025-04-17T15:50:01+00:00"},"adsId":0,"data":{"scripts":[{"pages":["all"],"location":"header","script":"<!--Optimizely Script-->\r\n<script src=\"https://cdn.optimizely.com/js/10563184655.js\"></script>","enabled":false},{"pages":["all"],"location":"header","script":"<!-- comScore Tag -->\r\n<script>var _comscore = _comscore || [];_comscore.push({ c1: \"2\", c2: \"15097263\" });(function() {var s = document.createElement(\"script\"), el = document.getElementsByTagName(\"script\")[0]; s.async = true;s.src = (document.location.protocol == \"https:\" ? \"https://sb\" : \"http://b\") + \".scorecardresearch.com/beacon.js\";el.parentNode.insertBefore(s, el);})();</script><noscript><img src=\"https://sb.scorecardresearch.com/p?c1=2&c2=15097263&cv=2.0&cj=1\" /></noscript>\r\n<!-- / comScore Tag -->","enabled":true},{"pages":["all"],"location":"footer","script":"<!--BEGIN QUALTRICS WEBSITE FEEDBACK SNIPPET-->\r\n<script type='text/javascript'>\r\n(function(){var g=function(e,h,f,g){\r\nthis.get=function(a){for(var a=a+\"=\",c=document.cookie.split(\";\"),b=0,e=c.length;b<e;b++){for(var d=c[b];\" \"==d.charAt(0);)d=d.substring(1,d.length);if(0==d.indexOf(a))return d.substring(a.length,d.length)}return null};\r\nthis.set=function(a,c){var b=\"\",b=new Date;b.setTime(b.getTime()+6048E5);b=\"; expires=\"+b.toGMTString();document.cookie=a+\"=\"+c+b+\"; path=/; \"};\r\nthis.check=function(){var a=this.get(f);if(a)a=a.split(\":\");else if(100!=e)\"v\"==h&&(e=Math.random()>=e/100?0:100),a=[h,e,0],this.set(f,a.join(\":\"));else return!0;var c=a[1];if(100==c)return!0;switch(a[0]){case \"v\":return!1;case \"r\":return c=a[2]%Math.floor(100/c),a[2]++,this.set(f,a.join(\":\")),!c}return!0};\r\nthis.go=function(){if(this.check()){var a=document.createElement(\"script\");a.type=\"text/javascript\";a.src=g;document.body&&document.body.appendChild(a)}};\r\nthis.start=function(){var t=this;\"complete\"!==document.readyState?window.addEventListener?window.addEventListener(\"load\",function(){t.go()},!1):window.attachEvent&&window.attachEvent(\"onload\",function(){t.go()}):t.go()};};\r\ntry{(new g(100,\"r\",\"QSI_S_ZN_5o5yqpvMVjgDOuN\",\"https://zn5o5yqpvmvjgdoun-wiley.siteintercept.qualtrics.com/SIE/?Q_ZID=ZN_5o5yqpvMVjgDOuN\")).start()}catch(i){}})();\r\n</script><div id='ZN_5o5yqpvMVjgDOuN'><!--DO NOT REMOVE-CONTENTS PLACED HERE--></div>\r\n<!--END WEBSITE FEEDBACK SNIPPET-->","enabled":false},{"pages":["all"],"location":"header","script":"<!-- Hotjar Tracking Code for http://www.dummies.com -->\r\n<script>\r\n (function(h,o,t,j,a,r){\r\n h.hj=h.hj||function(){(h.hj.q=h.hj.q||[]).push(arguments)};\r\n h._hjSettings={hjid:257151,hjsv:6};\r\n a=o.getElementsByTagName('head')[0];\r\n r=o.createElement('script');r.async=1;\r\n r.src=t+h._hjSettings.hjid+j+h._hjSettings.hjsv;\r\n a.appendChild(r);\r\n })(window,document,'https://static.hotjar.com/c/hotjar-','.js?sv=');\r\n</script>","enabled":false},{"pages":["article"],"location":"header","script":"<!-- //Connect Container: dummies --> <script src=\"//get.s-onetag.com/bffe21a1-6bb8-4928-9449-7beadb468dae/tag.min.js\" async defer></script>","enabled":true},{"pages":["homepage"],"location":"header","script":"<meta name=\"facebook-domain-verification\" content=\"irk8y0irxf718trg3uwwuexg6xpva0\" />","enabled":true},{"pages":["homepage","article","category","search"],"location":"footer","script":"<!-- Facebook Pixel Code -->\r\n<noscript>\r\n<img height=\"1\" width=\"1\" src=\"https://www.facebook.com/tr?id=256338321977984&ev=PageView&noscript=1\"/>\r\n</noscript>\r\n<!-- End Facebook Pixel Code -->","enabled":true}]}},"pageScriptsLoadedStatus":"success"},"navigationState":{"navigationCollections":[{"collectionId":287568,"title":"BYOB (Be Your Own Boss)","hasSubCategories":false,"url":"/collection/for-the-entry-level-entrepreneur-287568"},{"collectionId":293237,"title":"Be a Rad Dad","hasSubCategories":false,"url":"/collection/be-the-best-dad-293237"},{"collectionId":295890,"title":"Career Shifting","hasSubCategories":false,"url":"/collection/career-shifting-295890"},{"collectionId":294090,"title":"Contemplating the Cosmos","hasSubCategories":false,"url":"/collection/theres-something-about-space-294090"},{"collectionId":287563,"title":"For Those Seeking Peace of Mind","hasSubCategories":false,"url":"/collection/for-those-seeking-peace-of-mind-287563"},{"collectionId":287570,"title":"For the Aspiring Aficionado","hasSubCategories":false,"url":"/collection/for-the-bougielicious-287570"},{"collectionId":291903,"title":"For the Budding Cannabis Enthusiast","hasSubCategories":false,"url":"/collection/for-the-budding-cannabis-enthusiast-291903"},{"collectionId":299891,"title":"For the College Bound","hasSubCategories":false,"url":"/collection/for-the-college-bound-299891"},{"collectionId":291934,"title":"For the Exam-Season Crammer","hasSubCategories":false,"url":"/collection/for-the-exam-season-crammer-291934"},{"collectionId":301547,"title":"For the Game Day Prepper","hasSubCategories":false,"url":"/collection/big-game-day-prep-made-easy-301547"}],"navigationCollectionsLoadedStatus":"success","navigationCategories":{"books":{"0":{"data":[{"categoryId":33512,"title":"Technology","hasSubCategories":true,"url":"/category/books/technology-33512"},{"categoryId":33662,"title":"Academics & The Arts","hasSubCategories":true,"url":"/category/books/academics-the-arts-33662"},{"categoryId":33809,"title":"Home, Auto, & Hobbies","hasSubCategories":true,"url":"/category/books/home-auto-hobbies-33809"},{"categoryId":34038,"title":"Body, Mind, & Spirit","hasSubCategories":true,"url":"/category/books/body-mind-spirit-34038"},{"categoryId":34224,"title":"Business, Careers, & Money","hasSubCategories":true,"url":"/category/books/business-careers-money-34224"}],"breadcrumbs":[],"categoryTitle":"Level 0 Category","mainCategoryUrl":"/category/books/level-0-category-0"}},"articles":{"0":{"data":[{"categoryId":33512,"title":"Technology","hasSubCategories":true,"url":"/category/articles/technology-33512"},{"categoryId":33662,"title":"Academics & The Arts","hasSubCategories":true,"url":"/category/articles/academics-the-arts-33662"},{"categoryId":33809,"title":"Home, Auto, & Hobbies","hasSubCategories":true,"url":"/category/articles/home-auto-hobbies-33809"},{"categoryId":34038,"title":"Body, Mind, & Spirit","hasSubCategories":true,"url":"/category/articles/body-mind-spirit-34038"},{"categoryId":34224,"title":"Business, Careers, & Money","hasSubCategories":true,"url":"/category/articles/business-careers-money-34224"}],"breadcrumbs":[],"categoryTitle":"Level 0 Category","mainCategoryUrl":"/category/articles/level-0-category-0"}}},"navigationCategoriesLoadedStatus":"success"},"searchState":{"searchList":[],"searchStatus":"initial","relatedArticlesList":[],"relatedArticlesStatus":"initial"},"routeState":{"name":"ArticleCategory","path":"/category/articles/css3-34324/","hash":"","query":{},"params":{"category":"css3-34324"},"fullPath":"/category/articles/css3-34324/","meta":{"routeType":"category","breadcrumbInfo":{"suffix":"Articles","baseRoute":"/category/articles"},"prerenderWithAsyncData":true},"from":{"name":null,"path":"/","hash":"","query":{},"params":{},"fullPath":"/","meta":{}}},"profileState":{"auth":{},"userOptions":{},"status":"success"}}
Logo
  • Articles Open Article Categories
  • Books Open Book Categories
  • Collections Open Collections list
  • Custom Solutions

Article Categories

Book Categories

Collections

Explore all collections
BYOB (Be Your Own Boss)
Be a Rad Dad
Career Shifting
Contemplating the Cosmos
For Those Seeking Peace of Mind
For the Aspiring Aficionado
For the Budding Cannabis Enthusiast
For the College Bound
For the Exam-Season Crammer
For the Game Day Prepper
Log In
  • Home
  • Technology Articles
  • Programming & Web Design Articles
  • CSS3 Articles

CSS3 Articles

Give that website some style and get dynamic with the latest CSS and HTML5 standards, tricks, and workflows.

Articles From CSS3

Filter Results

4 results
4 results
CSS3 How to Detect the User’s Browser Type in CSS3

Article / Updated 11-05-2019

In most cases, developers don’t get to choose a user’s browser. To determine whether a particular user can work with your CSS3 application, then, you need first to detect the user’s browser — and then determine whether that browser is acceptable. Creating the code required to perform this task by hand isn’t impossible, but it can be hard. Articles like the one at Javascripter.net tell you how to perform this task, but one look at the code should tell you that it’s a complex task. (You can see the output from this example code here.) jQuery makes it possible to perform the detection with relative ease. The following example shows one method to detect the name and version of the user’s browser. It relies on the latest 1.x version of jQuery, which is version 1.10.1 at the time of this writing. (You can find complete code for this example in the Chapter 06jQuery folder of the downloadable code as BrowserDetect.html.) <!DOCTYPE html> <html> <head> <title>Detect a Browser</title> <script src="http://code.jquery.com/jquery-latest.js"> </script> <script src="http://code.jquery.com/jquery-migrate-1.2.1.js"> </script> </head> <body> <h1>Browser Information</h1> <p id="name"></p> <script language="JavaScript"> var browser = $.uaMatch(navigator.userAgent).browser; $('p[id="name"]').html( "Browser Name: <span>" + browser + "</span>"); </script> <p id="version"></p> <script language="JavaScript"> $('p[id="version"]').html( "Version Number: <span>" + $.browser.version + "</span>"); </script> </body> </html> This is an HTML5 page, so it starts with the HTML declaration, . This example begins with a basic structure that includes the , , , and <body> tags. The code begins with the first <script> tag that uses the src attribute to tell the browser where to find the jQuery library. You can copy this information as shown to any page where you want to use jQuery. Anyone who uses the application will automatically have access to jQuery as long as the browser can access the Internet. (You can also download a copy of jQuery for local access from the jQuery site.) <p class="Remember">The latest 1.<i>x</i> version of jQuery doesn’t support the browser detection feature directly. In order to make the feature work with anything newer than jQuery 1.8.3, you must also include the link for the <a href="http://code.jquery.com/jquery-migrate-1.2.1.js">jQuery Migrate library</a> as shown in the example.</p> The <body> of the page starts out with a <h1> tag that contains the page’s heading. The next step is to provide a place for jQuery to put the browser’s name. In this case, the example uses a <p> (paragraph) tag that has an id of name. The first <script> creates a var (variable) named browser and places the browser’s name in it. The browser name is always provided to your application as part of the JavaScript navigator.userAgent object, but working with this object is time-consuming, so this code shows a one-line method for obtaining the information. It’s time to display the name onscreen. The $ (dollar sign) is a special symbol that refers to the jQuery library, which is also called an Application Programming Interface (API). The bit of code that says, $('p[id="name"]').html, tells jQuery to use the <p> tag with an id value of name to hold some HTML. This is a kind of selector. You now have a specific tag selected. The code then tells jQuery to create some text, a <span>, and then place the name of the browser within that span. All this information appears in the <p> tag after the script executes. Next comes a second <p> tag. This one has an id attribute of version. The accompanying script starts out the same as before. The $('p[id="version"]').html entry tells jQuery to place some HTML in the <p> tag with an id attribute of version. In this case, jQuery provides what you need as a property. All the code has to do is tell jQuery to place the value in browser.version within the <p> tag to display the browser’s version number. When you run this example, you see output similar to this: <img src="https://www.dummies.com/wp-content/uploads/414707.image0.jpg" alt="image0.jpg" width="492" height="194" /> <p class="Remember">A library can detect only the browsers it’s designed to detect. Consequently, jQuery detects some browsers, but not others. For example, you can’t currently use it to detect an Android browser because Android isn’t in the list of browsers supported by jQuery (which focuses on desktop browsers).</p> Most browser detection methods rely on user agent strings that contain information about the browser. To see the user agent string for your browser, check out <a href="https://www.whoishostingthis.com/tools/user-agent/">Who is Hosting This</a> You can generally find lists of user agent strings for devices online.

View Article
CSS3 How to Create External Styles in CSS3

Article / Updated 03-26-2016

Most developers use external styles in CSS3 to reduce the amount of work required to maintain a site. A single .CSS file contains all of the styles for the site, which means that changing a style site-wide is as simple as changing that one file (rather than each page). Because the change occurs in just one place, there isn’t any chance of missing one or more changes on individual pages. Creating and using an external style sheet isn’t much different from using an internal style sheet. The following example uses standard techniques to create an external style sheet: Create a new HTML5 file with your text editor. Type the code for the HTML page. <!DOCTYPE html> <html> <head> <title>A Simple Page</title> </head> <body> <h1>A Simple Heading</h1> <p>Simple text to go with the heading.</p> </body> </html> Make sure you type the code precisely. What you should end up with is the same plain page — one without any styles. Type the following code immediately after the tag.</p> <pre class="code"><link rel="stylesheet" href="ExternalCSS.CSS" /></pre> <p class="child-para">The <link> tag tells the browser to look for an external resource. In this case, the rel attribute says that it should look for a style sheet and the href attribute provides the name of that style sheet.</p> </li> <li><p class="first-para">Save the HTML5 file to disk.</p> </li> <li><p class="first-para">Create a new .CSS file with your text editor.</p> <p class="child-para">Your editor may not support .CSS files. Any text file will do.</p> </li> <li><p class="first-para">Type the following code in the .CSS file.</p> <pre class="code">p { font-family: cursive; font-size: large; color: #0000ff; background-color: #ffff00; } h1 { font-family: "Times New Roman",Georgia,serif; font-size: 40px; text-align: center; text-decoration: underline; color: #ff0000; background-color: #00ffff; }</pre> <p class="child-para">This may be the same code that you used to create your internal file. The only difference is that it now resides in an external file.</p> </li> <li><p class="first-para">Save the CSS file to disk as ExternalCSS.CSS.</p> <p class="child-para">It’s absolutely essential that the name of the file precisely match the name found in the href attribute. Some platforms are case sensitive, so you must use the same case for the filename. For example, externalcss.css might be viewed as a different file from ExternalCSS.CSS.</p> </li> <li><p class="first-para">Load the page in your browser.</p> <img src="https://www.dummies.com/wp-content/uploads/414625.image0.jpg" width="460" height="169" alt="image0.jpg"/> </li> </ol>

View Article
CSS3 How to Use Multiple Styles Together with CSS3

Article / Updated 03-26-2016

Understanding the rules of inheritance in CSS3 helps you create interesting sites that require a minimum of maintenance. By following these rules, when maintenance is required, you normally have to make just one change, rather than changing hundreds of items individually. It pays to experiment, though, so you can understand the full effects of inheritance and the effects of using multiple styles together. Create a new HTML5 file with your text editor. Your editor may not support HTML5 files. Any text file will do. Type the following code for the HTML page. <!DOCTYPE html> <html> <head> <title>Inheritance Example</title> <style> p { font-family: Arial, Helvetica, sans-serif; color: Blue; background-color: Yellow; margin: 0; font-style: italic; font-size: medium; } div p { font-style: italic; font-size: larger; } </style> </head> <body> <h1>An Example of CSS Inheritance</h1> <p>A paragraph outside a <span style="font-family: monospace"> <div></span>.</p> <div id="Container" style="text-align: left;"> <p>A paragraph inside a container.</p> </div> </body> </html> This page contains a number of inline styles, which always have the highest inheritance precedence. For example, the provides a font-family of monospace for the tag part of the sentence. You could accomplish the same thing by assigning the a class attribute for code, but this example uses the inline style instead. The uses an inline style to set the text-align style to left. Because the default style sets the alignment to left, you won’t see any difference. However, if another style change modifies the text alignment, this style will take effect and prevent movement of this paragraph. The internal style modifications all appear within the tag in the <head> element. The first style sets the general characteristics for a <p> tag. Notice that the style specifically sets the font-style to italic and the font-size to medium.</p> <p class="child-para">The second style is more specific. It sets the characteristics for <p> tags that appear as a child of a <div>. Consequently, inheritance rules say that this style will take precedence when the rules of inheritance are met, which means the font-style and font-size styles will be different in this case.</p> </li> <li><p class="first-para">Save the file as Inheritance.HTML.</p> </li> <li><p class="first-para">Load the Inheritance example into your browser.</p> <p class="child-para">You see the role that inheritance and cascading styles play.</p> <img src="https://www.dummies.com/wp-content/uploads/414686.image0.jpg" width="535" height="183" alt="image0.jpg"/> </li> <li><p class="first-para">Create a new CSS file with your text editor.</p> <p class="child-para">Your editor may not support CSS files. Any text file will do.</p> </li> <li><p class="first-para">Type the following CSS style information.</p> <pre class="code">body { text-align: center; color: DarkRed; background-color: Khaki; border: inset; border-color: Green; } h1 { border: outset; border-color: Brown; } p { text-decoration: underline; font-family: "Times New Roman", Times, serif; font-style: oblique; font-size: xx-large; }</pre> <p class="child-para">The <body> tag appears as the topmost object in a page, so the changes noted in the body style should affect everything not specifically overridden later. In this case, the example changes the text alignment to center and places a dark red border around any content. The background color is also changed. Finally, the style adds a green border around every object.</p> <p class="child-para">The h1 style overrides any body styles. In this case, that means modifying the border styles.</p> <p class="child-para">The p style also overrides any body styles. However, there aren’t any properties that are the same in this case, so the p styles enhance the styles inherited from the body style.</p> </li> <li><p class="first-para">Save the file as Inheritance.CSS.</p> </li> <li><p class="first-para">Add the following code to the <head> area of the HTML file.</p> <pre class="code">&lt;link rel="stylesheet" href="Inheritance.CSS" /&gt;</pre> <p class="child-para">This code creates the link between the HTML file and the CSS file.</p> </li> <li><p class="first-para">Save the HTML file and reload the page.</p> <img src="https://www.dummies.com/wp-content/uploads/414687.image1.jpg" width="535" height="182" alt="image1.jpg"/> <p class="child-para">Notice that all the expected changes are in place. For example, the text is centered, except for the one paragraph that has an inline style overriding the centered text. The heading text is now in dark red — the paragraph text overrides that color selection, so it remains blue. Even though there is an external p style for the size of the text, the internal style overrides it.</p> <p class="child-para">You should notice something else about the example. The body contains an inset border of the correct color and the heading contains an outset border of the correct color, because it has overridden the default.</p> <p class="child-para">However, the paragraphs have no border. At one time, <body> tag changes affected the entire document and some of them still do. However, other changes affect only the body and not other block elements. Block elements don’t inherit some settings from the body style.</p> </li> <li><p class="first-para">Delete the h1 style from the Inheritance.CSS style sheet.</p> <p class="child-para">You can also comment out the h1 style by adding the starting (/*) and ending (*/) comment symbols to it like this:</p> <pre class="code">/* Commented out to show block settings. h1 { border: outset; border-color: Brown; } */</pre> </li> <li><p class="first-para">Save the CSS file and reload the page.</p> <img src="https://www.dummies.com/wp-content/uploads/414688.image2.jpg" width="535" height="184" alt="image2.jpg"/> <p class="child-para">Notice that the heading now lacks a border. It turns out that the heading wasn’t overriding the body-level border — it was adding a new border. Never assume that a body style will carry through to other block-level styles — some settings simply don’t. When you find that your page doesn’t look as you expected it to look, try configuring the setting at a lower block level.</p> <p class="child-para">You may also see some style sheets that access the html style, which affects the <html> tag that contains the <body> tag. It’s true: You can work with the html style to achieve some effects.</p> </li> <li><p class="first-para">Add the html style shown here to the Inheritance.CSS style sheet.</p> <pre class="code">html { border: outset; border-color: Green; background-color: White; }</pre> </li> <li><p class="first-para">Save the CSS file and reload the page.</p> <img src="https://www.dummies.com/wp-content/uploads/414689.image3.jpg" width="535" height="182" alt="image3.jpg"/> <p class="child-para">You rarely have to rely on the html style because it simply isn’t necessary. The html block is a level above the body block, as shown by this example. The html block doesn’t give you access to anything that the body block can’t change in most cases, except for special effects like the one shown here.</p> </li> </ol>

View Article
CSS3 Using the Div Tag to Create Tables

Article / Updated 03-26-2016

Creating tables can be error prone and difficult using the older HTML tags. In addition, they prove inflexible at times. It’s possible to create tables using another technique. All you need is a series of cascading tags to perform the task. Credit: ©iStockphoto.com/Anton Cherstvenkov Many developers have used tables for all sorts of tasks in the past. Of course, there is the use of tables to display data. However, tabular arrangements are also useful for creating forms to ensure the various elements align in a predictable manner. This second use of tables is problematic because it confuses some software such as screen readers. The problem becomes one of defining a well-organized page without creating problems for the people viewing it. Using tags to create a table makes it possible for viewers to see a table or a logical arrangement of controls with equal ease. This technique also has the benefit of not confusing screen readers and other software. Defining the HTML for a table looks somewhat like creating a table using the older tags, except you don’t have to worry about odd arrangements of arcane tags to do it. Here is the HTML for a table that contains a title, headings, and two rows of content. <div class="Table"> <div class="Title"> <p>This is a Table</p> </div> <div class="Heading"> <div class="Cell"> <p>Heading 1</p> </div> <div class="Cell"> <p>Heading 2</p> </div> <div class="Cell"> <p>Heading 3</p> </div> </div> <div class="Row"> <div class="Cell"> <p>Row 1 Column 1</p> </div> <div class="Cell"> <p>Row 1 Column 2</p> </div> <div class="Cell"> <p>Row 1 Column 3</p> </div> </div> <div class="Row"> <div class="Cell"> <p>Row 2 Column 1</p> </div> <div class="Cell"> <p>Row 2 Column 2</p> </div> <div class="Cell"> <p>Row 2 Column 3</p> </div> </div> </div> Notice that each level is defined using an easily recognized name, such as Table, Title, Heading, Row, and Cell. Using this naming method makes it a lot easier to figure out what each level of the table is supposed to do. You can find many different alternatives to this approach online, but this basic approach will serve you well. The CSS for this table uses a few special properties and a little clever formatting. Here is the CSS used to make this example functional. <style type="text/css"> .Table { display: table; } .Title { display: table-caption; text-align: center; font-weight: bold; font-size: larger; } .Heading { display: table-row; font-weight: bold; text-align: center; } .Row { display: table-row; } .Cell { display: table-cell; border: solid; border-width: thin; padding-left: 5px; padding-right: 5px; } </style> Notice the use of the display property. This is the crucial property for your table because it tells the browser how to display a particular element. Otherwise, there isn’t anything strange of out of the normal about these styles. You define text attributes that help viewers differentiate between various table elements. Cells are separated from each other using a simple border. The following figure shows you how the table will appear when you view it in a browser.

View Article

Quick Links

  • About For Dummies
  • Contact Us
  • Activate Online Content

Connect

About Dummies

Dummies has always stood for taking on complex concepts and making them easy to understand. Dummies helps everyone be more knowledgeable and confident in applying what they know. Whether it's to pass that big test, qualify for that big promotion or even master that cooking technique; people who rely on dummies, rely on it to learn the critical skills and relevant information necessary for success.

Copyright @ 2000-2024 by John Wiley & Sons, Inc., or related companies. All rights reserved, including rights for text and data mining and training of artificial technologies or similar technologies.

Terms of Use
Privacy Policy
Cookies Settings
Do Not Sell My Personal Info - CA Only