CSS – Pointer Events

CSS – pointer-event Property ”; Previous Next CSS pointer-event property is used to control how an element responds to pointer events such as mouse clicks, mouseovers, and mouse movements. It allows you to specify whether an element should receive pointer events and whether those events should trigger actions like clicking or hovering. Possible Values auto − : This is the default value. It indicates that the element behaves as normal and responds to pointer events based on its specified CSS properties and content. In SVG content, this value and visiblePainted have the same effect. none − This value indicates that the element should not respond to pointer events. Clicks, hover effects, and other interactions will pass through the element as if it were not there, and the elements beneath it will receive those events instead. visiblePainted − This value indicates that the element does not receive pointer events unless they are triggered on a visible, painted area of the element. Transparent areas within the element do not respond to pointer events.. visibleFill − Similar to visiblePainted, this value indicates that the element only responds to pointer events triggered on visible, painted areas or the fill of the element, ignoring pointer events on transparent areas. visibleStroke − Similar to visiblePainted and visibleFill, this value indicates that the element only responds to pointer events triggered on visible, painted areas or the stroke of the element, ignoring pointer events on transparent areas. visible − Targets pointer events only when the visibility is set to visible. and the mouse cursor is over its interior (fill) or perimeter (stroke), with the fill and stroke values not affecting event processing painted − This value indicates that the element only responds to pointer events triggered on its painted content. Transparent areas within the element do not respond to pointer events. fill − Similar to painted, this value indicates that the element only responds to pointer events triggered on its fill, ignoring events on transparent areas. stroke − Similar to painted and fill, this value indicates that the element only responds to pointer events triggered on its stroke, ignoring events on transparent areas. all − Targets to pointer events when the pointer is over their interior (fill) or perimeter (stroke). The fill, stroke and visibility properties values are unaffected. Applies To All elements. Syntax pointer-event: auto | none | visiblePainted | visibleFill | visibleStroke | visible | painted | fill | stroke | all; Points To Remember When this property is not defined, SVG content has the same properties as the visiblePainted value. The “one value in pointer events not only makes the element the target rather than the pointer event, but it also allows the event to pass through, targeting what is underneath the element. Disabling pointer events on an element using pointer-events does not mean that event listeners will not be triggered. If a child of that element has pointer-events enabled to allow it to be the event target, events aimed at the child will pass via the parent, potentially triggering event listeners. However, if the pointer activity occurs in an area only covered by the parent, it will be missed by both the child and the parent. Elements with pointer-events: none will still get focus via sequential keyboard navigation with the Tab key. CSS pointer-event – none Value The following example demonstrates how the pointer-event: none property disables the hyperlink from being clicked − <html> <head> <style> a[href=”https://tutorialspoint_css_pointer-event.com”] { pointer-events: none; } </style> </head> <body> <a href=”https://tutorialspoint_css_pointer-event.com”>css_pointer-event</a> </body> </html> CSS pointer-event – auto Value The following example demonstrates the pointer-event: auto property allows the anchor element to be clickable − <html> <head> <style> a[href=”https://tutorialspoint_css_pointer-event.com”] { pointer-events: auto; } </style> </head> <body> <a href=”https://tutorialspoint_css_pointer-event.com”>css_pointer-event</a> </body> </html> CSS pointer-event – Disabling Pointer Events on Images The following example demonstrates the pointer-event: auto property disables pointer events (clicking, hovering, etc.) on an images − <html> <head> <style> img { height: 100px; width: 100px; pointer-events: none; } </style> </head> <body> <img src=”images/pink-flower.jpg” alt=”pink-flower”> </body> </html> Print Page Previous Next Advertisements ”;

CSS – Icons

CSS – Icons ”; Previous Next CSS icons are used to add graphical representations, symbols, or small images to web elements. They serve several purposes in web development, such as: Table of Contents Importance of Icon How to add Icons to a Webpage? Icons using SVG Icons using icon fonts Icons using images Icons using Pseudo-Elements Icons using Google Icons Bootstrap Icons   Importance of Icon Enhanced user experience: Provides visual cues and context to various elements on a webpage, like instead of adding the text save, delete, etc. you may add an icon to represent them. Reduced load time: CSS icons are often lightweight compared to traditional image icons, which means they can load quickly, reducing the overall page load time. Scalability: CSS icons can be easily scaled up or down without loss of quality. It is important for responsive web designing. Customization: CSS icons can be customized by changing their size, color, and other visual properties using CSS rules. This flexibility allows you to match the icons to your website”s overall design and branding. Accessibility: CSS icons can be styled to meet accessibility standards, such as providing alternative text for screen readers. Reduced HTTP Requests: Using CSS icons can reduce the number of HTTP requests made by a webpage since they are often part of the stylesheet. How to Add Icons to a Webpage? Inline SVGs: Involves embedding SVG (Scalable Vector Graphics) directly into your HTML code. You can create or obtain SVG icons and insert them as inline elements. Icon fonts: Icon fonts are custom fonts that contain icons as glyphs. You can use these fonts to display icons by setting the appropriate font-family and specifying the icon”s Unicode character. CSS background images: You can use CSS background images to display icons by setting the background-image property on an element. Pseudo-elements: Involves using the ::before and ::after pseudo-elements to insert content before or after an HTML element and then styling that content to display an icon. CSS Libraries and Frameworks: Many CSS libraries and frameworks, like Font Awesome, Material Icons, and Google Icons, provide pre-designed sets of icons that you can easily include in your projects. They often come with ready-to-use classes or utility classes. Icons Using SVG In HTML <svg> tag can be used to create custom icons using d attribute of <path>. The d attribute of the <path> tag in SVG defines the shape of the path using a series of commands and parameters in a predefined syntax, representing lines, curves, and other geometric shapes. These commands include moveto (M), lineto (L), curveto (C), and others, each followed by coordinates or control points that specify the path”s structure. Example <!DOCTYPE html> <html> <head> <style> .icon { width: 24px; height: 24px; fill: #000; margin-left: 15px; } </style> </head> <body> <h1>SVG Icons</h1> <!– Search Icon –> <svg class=”icon” xmlns=”http://www.w3.org/2000/svg” viewBox=”0 0 24 24″> <path d=”M23.707 22.293l-6.364-6.364C18.454 14.68 19 13.418 19 12c0-3.866-3.134-7-7-7s-7 3.134-7 7 3.134 7 7 7c1.418 0 2.68-.546 3.929-1.071l6.364 6.364a1 1 0 0 0 1.414-1.414zM5 12c0-3.309 2.691-6 6-6s6 2.691 6 6-2.691 6-6 6-6-2.691-6-6z”/> </svg> <!– Download Icon –> <svg class=”icon” xmlns=”http://www.w3.org/2000/svg” viewBox=”0 0 24 24″> <path d=”M19 14v7H5v-7H3v7c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2v-7h-2zm-7-9h2v7h3l-4 4-4-4h3V5zm-1-2h4V0h-4v3z”/> </svg> <!– Cloud Icon –> <svg class=”icon” xmlns=”http://www.w3.org/2000/svg” viewBox=”0 0 24 24″> <path d=”M19.35 10.04c.63-.34 1.22-.79 1.68-1.35C21.47 6.39 19.76 4 17 4c-2.33 0-4.31 1.45-5.13 3.5H11.5C8.42 7.5 6 9.92 6 13s2.42 5.5 5.5 5.5h7c3.04 0 5.5-2.46 5.5-5.5-.01-2.52-1.65-4.67-4-5.46l.35.5z”/> </svg> <!– Home Icon –> <svg class=”icon” xmlns=”http://www.w3.org/2000/svg” viewBox=”0 0 24 24″><path d=”M12 2l10 9h-3v11h-6V14H9v8H3V11H0l12-9z”/> </svg> </body> </html> Icons Using Icon Fonts To use icon fonts in your web project, you need to follow this steps: Include the icon font library, Popular choices include Font Awesome, Material Icons, or custom icon fonts. Use <i> tag in HTML and apply the icon font class to it. Then, specify the Unicode character for the desired icon. Example <!DOCTYPE html> <html> <head> <!– Include Font Awesome –> <link rel=”stylesheet” href= “https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css”> <style> .icon { /* Specify Font Awesome family */ font-family: “Font Awesome 5 Free”; /* Minimum Font weight for Font Awesome */ font-weight: 600; font-size: 24px; color: #000; margin-right: 15px; } </style> </head> <body> <h1>CSS font Awesome Icons</h1> <span class=”icon”> &amp#xf002; </span> <span class=”icon”> &amp#xf019; </span> <span class=”icon”> &amp#xf0c2; </span> <span class=”icon”> &amp#xf015; </span> </body> </html> Icons Using Images The background-image property in CSS can also used to display icons that are stored at system storage. Example Following example demonstrates using background image as an icon: <DOCTYPE html> <html> <head> <style> .icon-img { width: 30px; height: 30px; background-image: url(”/css/images/logo.png”); background-size: cover; } </style> </head> <body> <div class=”icon-img”> </div> </body> </html> Icons Using Pseudo-Elements Pseudo-elements like ::before and ::after can be used to insert an icon before or after an element as demonstrated in the following example. To know more about pseudo-elements check out tutorial on CSS Pseudo-Elements. Example Here in this example we use pseudo element to render icons. <DOCTYPE html> <html> <head> <style> li { list-style: none; } li::before { content: url(/css/images/smiley.png); margin-right: 15px; font-size: 20px; } p::after { content: url(/css/images/smiley.png); margin-left: 15px; font-size: 5px; } </style> </head> <body> <ul> <li>Butterscotch</li> <li>Chocolate</li> <li>Coconut</li> </ul> <p> In the above list we made custom label using before pseudo-element, we added icon at the end of this paragraph using ::after pseudo-element. </p> </body> </html> Icons Using Google

CSS – Counters

CSS – Counters ”; Previous Next In CSS, counters act as variables that are used for numbering purposes. They can be increased or decreased by css rules. Css counters enable us to modify the presentation of content depending on its position. For instance you can use the counters to automatically assign numbers to paragraphs, headings and lists. CSS Counters – Nesting Counters We can use the counters() function along with the counter-reset and counter-increment properties to create outlined lists with nested counters. This technique allows you to automatically generate counters for different levels of nesting. This following example creates a nested structure using the <ol> element to demonstrate the nesting of counters. <html> <head> <title>Nesting of Counter</title> <style> ol { counter-reset: section; list-style-type: none; } li::before { counter-increment: section; content: counters(section, “.”) ” “; } </style> </head> <body> <ol> <li>Section 1 <ol> <li>Subsection 1.1</li> <li>Subsection 1.2</li> <li>Subsection 1.3</li> </ol> </li> <li>Section 2 <ol> <li>Subsection 2.1</li> <li>Subsection 2.2</li> <li>Subsection 2.3</li> </ol> </li> <li>Section 3 <ol> <li>Subsection 3.1</li> <li>Subsection 3.2</li> <li>Subsection 3.3</li> </ol> </li> </ol> </body> </html> CSS Counters – Reversed counter A reversed counter is a special kind of counter that counts backwards instead of forward. To create a reversed counter, name it with the reversed() function when you set it up with counter-reset. The reversed counters start with a default initial value equal to the number of elements, not zero. This means that it can simply count down from the number of elements to one. Syntax counter-reset: reversed(counter name); The reversed counter property is supported only by Firefox browser The following example demonstrates reversed counter (Execute this example in Firefox browser). <html> <head> <style> body { counter-reset: reversed( section); } p::before { counter-increment: section -1; content: “Section ” counter(section) “: “; } </style> </head> <body> <p>This is fourth paragraph</p> <p>This is Third paragraph</p> <p>This is second paragraph</p> <p>This is first paragraph</p> </body> </html> The name of the counter should not be none, inherit or initial. If this is the case, the declaration is neglected. CSS Counter – Related Properties Following is the list of CSS properties of counter: property value counter-reset It is used to create or reset a counter. counter-set It is used to set a counter to given value. counter-increment It is used to increment the counter value. counter() It provides a string that represents the current value of named counter. counters() It is used to work with nested counters. @counter-styles It is used to create custom counter styles. contain Determines how the content of an element behaves when it is too wide to fit inside its container. Print Page Previous Next Advertisements ”;

CSS – Outlines

CSS – Outlines ”; Previous Next Outlines are very similar to borders, but there are few major differences as well − An outline does not take up space. Outlines do not have to be rectangular. Outline is always the same on all sides. You cannot specify different values for outline on different sides of an element. NOTE − The outline properties are not supported by IE 6 or Netscape 7. You can set the following outline properties using CSS. The outline-width property is used to set the width of the outline. The outline-style property is used to set the line style for the outline. The outline-color property is used to set the color of the outline. The outline-offset property is used to set the space between the outline and border edge of ab element. The outline property is used to set all the above three properties in a single statement. The outline-width Property The outline-width property specifies the width of the outline to be added to the box. Its value should be a length or one of the values thin, medium, or thick, just like the border-width attribute. A width of zero pixels means no outline. Here is an example − <html> <head> </head> <body> <p style = “outline-width: thin; outline-style: solid; padding: 5px”> This text is having thin outline. </p> <p style = “outline-width: thick; outline-style: solid; padding: 5px”> This text is having thick outline. </p> <p style = “outline-width: 5px; outline-style: solid; padding: 5px”> This text is having 5px outline. </p> </body> </html> The outline-style Property The outline-style property specifies the style for the line (solid, dotted, or dashed) that goes around an element. It can take one of the following values − none − No outline. (Equivalent of outline-width:0;) solid − Outline is a single solid line. dotted − Outline is a series of dots. dashed − Outline is a series of short lines. double − Outline is two solid lines. groove − Outline looks as though it is carved into the page. ridge − Outline looks the opposite of groove. inset − Outline makes the box look like it is embedded in the page. outset − Outline makes the box look like it is coming out of the canvas. hidden − Same as none. Here is an example − <html> <head> </head> <body> <p style = “outline-width: thin; outline-style: solid; padding: 5px”> This text is having thin solid outline. </p> <p style = “outline-width: thick; outline-style: dashed; padding: 5px”> This text is having thick dashed outline. </p> <p style = “outline-width: 5px; outline-style: dotted; padding: 5px”> This text is having 5px dotted outline. </p> </body> </html> The outline-color Property The outline-color property allows you to specify the color of the outline. Its value should either be a color name, a hex color, or an RGB value, as with the color and border-color properties. Here is an example − <html> <head> </head> <body> <p style = “outline-width: thin; outline-style: solid; outline-color: red; padding: 5px”> This text is having thin solid red outline. </p> <p style = “outline-width: thick; outline-style: dashed; outline-color: #009900; padding: 5px”> This text is having thick dashed green outline. </p> <p style = “outline-width: 5px; outline-style: dotted; outline-color: rgb(13,33,232); padding: 5px”> This text is having 5px dotted blue outline. </p> </body> </html> The outline-offset Property The outline-offset property is used to specify the space between an outline and the border edge of an element. The space between the outline and the element is transparent. Here is an example − <html> <head> <style> div.example { margin: 20px; border: 2px dotted #000; background-color: #08ff90; outline: 4px solid #666; outline-offset: 10px; } </style> </head> <body> <h2>Outline-offset property</h2> <div class=”example”>The outline-offset is 10px</div> </body> </html> The outline Property The outline property is a shorthand property that allows you to specify values of different properties in a single statement. The values that can be passed are outline-style, outline-color and outline-width. The order in which the values can be passed is not fixed. outline-offset cannot be passed as a shorthand property in outline. It needs to be passed separately. Here is an example − <html> <head> </head> <body> <p style = “outline: thin solid red; padding: 10px;”> This text is having thin solid red outline. </p> <p style = “outline: thick dashed #009900; padding: 10px;”> This text is having thick dashed green outline. </p> <p style = “outline: 5px dotted rgb(13,33,232); padding: 10px;”> This text is having 5px dotted blue outline. </p> </body> </html> Outline vs Border Following table illustrates the differences between outline and border: Outline Border Outline is a non-rectangular shape that surrounds an element, usually with a solid color. Border is a rectangular shape that is drawn around the content of an element, can be solid, dashed, or dotted, and can have different colors and sizes. It does not take up any space in the layout and does not affect the size or position of the element. It affects the size and position of the element, as it adds width to the element. It is typically used to highlight or emphasize an element, such as when an element is focused or activated. It can be used for various purposes, such as separating elements, creating boxes, and adding visual emphasis. It can be created using the outline property in CSS. It can be created using the border property in CSS.

CSS – Isolation

CSS – isolation ”; Previous Next CSS isolation property is used to control how an element”s content interacts with its parent and sibling elements in terms of rendering and stacking context. It essentially determines whether an element establishes a new stacking context or not. Possible Values auto − This is the default value. It indicates that the element”s content does not create a new stacking context. Instead, it inherits the stacking context of its parent. isolate − This value indicates that the element creates a new stacking context, isolating its content from the rest of the document. This means that the element”s content will be rendered independently of its siblings and parent elements. Applies To All elements. In SVG, it applies to container elements, graphics elements, and graphics referencing elements. Syntax isolation: auto | isolate; CSS isolation – auto Value The following example demonstrates the isolation: auto property creating a new stacking context. The mix-blend-mode: difference subtracts the top color from the bottom color and creating in a high-contrast effect − <html> <head> <style> .container { background-color: yellow; width: 250px; height: 200px; padding: 5px; } .box2 { width: 130px; height: 130px; border: 5px solid red; padding: 5px; mix-blend-mode: difference; margin-left: 50px; } .box1 { isolation: auto; } </style> </head> <body> <div class=”container”> <div class=”box1″> <h3 class=”container box2″>isolation: auto;</h3> </div> </div> </body> </html> CSS isolation – isolate Value The following example demonstrates the isolation: isolate property that creates a new stacking context for box1, preventing the box1 from blending with external elements and the blend mode applied to box2 doesn”t impact elements inside box1 − The mix-blend-mode: difference property subtracts the top color from the bottom color and creating high-contrast effect. <html> <head> <style> .container { background-color: yellow; width: 250px; height: 200px; padding: 5px; } .box2 { width: 130px; height: 130px; border: 5px solid red; padding: 5px; mix-blend-mode: difference; margin-left: 50px; } .box1 { isolation: isolate; } </style> </head> <body> <div class=”container”> <div class=”box1″> <h3 class=”container box2″>isolation: isolate;</h3> </div> </div> </body> </html> Print Page Previous Next Advertisements ”;

CSS – Navbar

CSS – Navigation Bar ”; Previous Next Navigation bar is a section of a graphical user interface (GUI) that helps users navigate through a website, app, or other software. It is essential for users to quickly and easily navigate to the content they are looking for. The navigation bar can be horizontal or vertical, that contains links to important pages or features. Table of Contents How to Design a Responsive Navbar? CSS Horizontal Navbar CSS Vertical Navbar CSS Fixed Navbar Divider Lines for Navbar Fixed Vertical Navbar CSS Dropdown Navbar   How to Design a Responsive Navbar? Following are common steps followed to design a navbar in CSS: HTML Structure: Use anchor tag ( <a> ) inside unordered list ( <ul> ) to obtain structure of navbar. Remove Default Styles: Use the property ”list-style-type: none” to remove default styling and label of unordered list. Flex Layout: Use the property display: flex for ul element and set flex-direction as row or column depending upon horizontal or vertical flexbox needed. Responsive Design: Use CSS media queries to change between horizontal and vertical layout of navbar depending upon user screen width. Hamburger Menu: Create a hamburger menu icon that toggles the visibility of the list on smaller screens. Navbars can also contain other elements, such as the logo of the website or app, search bar, or social media icons. Navbars can be styled using CSS to change their appearance. CSS Horizontal Navbar Following example shows a horizontal navigation bar, which is the most common type of navigation bar displayed across the top of a web page as shown below Example <!DOCTYPE html> <html> <head> <style> body{ color: #4CAF50; } ul { background-color: #333; overflow: hidden; list-style-type: none; margin: 0; padding: 0; width: 100%; display: flex; flex-direction: row; } li a { display: block; color: #f2f2f2; text-align: center; padding: 14px 20px; text-decoration: none; font-size: 18px; transition: background-color 0.3s, color 0.3s; } li a:hover { background-color: #575757; color: #ffffff; } .active-link { background-color: #4CAF50; color: white; } </style> </head> <body> <ul> <li class=”active-link”> <a href=”#” >Tutorialspoint</a> </li> <li> <a href=”#”>Home</a> </li> <li> <a href=”#”>Articles</a> </li> <li> <a href=”#”>Courses</a> </li> </ul> <h1> Welcome to TutorialsPoint </h1> <h3> Simple Easy Learning at your fingertips </h3> </body> </html> CSS Vertical Navbar A vertical navigation bar is also known as a sidebar menu. It is typically positioned on the left or right side of the screen. Example <!DOCTYPE html> <html> <head> <style> body{ color: #4CAF50; display: flex; flex-direction: row; gap: 10px; } ul { background-color: #333; overflow: hidden; list-style-type: none; margin: 0; padding: 0; display: flex; flex-direction: column; } li a { display: block; color: #f2f2f2; text-align: center; padding: 14px 20px; text-decoration: none; font-size: 18px; transition: background-color 0.3s, color 0.3s; } li a:hover { background-color: #575757; color: #ffffff; } .active-link { background-color: #4CAF50; color: white; } </style> </head> <body> <ul> <li class=”active-link”> <a href=”#” >Tutorialspoint</a> </li> <li> <a href=”#”>Home</a> </li> <li> <a href=”#”>Articles</a> </li> <li> <a href=”#”>Courses</a> </li> </ul> <div> <h1> Welcome to TutorialsPoint </h1> <h3> Simple Easy Learning at your fingertips </h3> </div> </body> </html> CSS Dropdown Navbar A dropdown navbar is a navigation bar with a drop-down menu that appears when a user hovers over a link. Dropdown menus are a way to show a list of related items in a small space. Example <!DOCTYPE html> <html> <head> <link rel=”stylesheet” href= “https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css”> <style> .navbar { background-color: #2c3e50; overflow: hidden; } .navbar a { display: block; float: left; color: #ecf0f1; text-align: center; padding: 14px 20px; text-decoration: none; font-size: 16px; transition: background-color 0.3s, color 0.3s; } .navbar a:hover { background-color: #34495e; color: #ecf0f1; } .active-link { background-color: #4CAF50; color: white; } .dropdown { float: left; } .dropdown .dropbtn { border: none; color: #ecf0f1; padding: 14px 20px; background-color: #2c3e50; font-size: 16px; cursor: pointer; transition: background-color 0.3s, color 0.3s; } .dropdown .dropbtn:hover { background-color: #4CAF50; color: #ecf0f1; } .dropdown-content { display: none; position: absolute; background-color: #34495e; min-width: 160px; box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2); z-index: 1; } .dropdown-content a { float: none; color: #ecf0f1; padding: 12px 16px; text-decoration: none; display: block; text-align: left; transition: background-color 0.3s, color 0.3s; } .dropdown-content a:hover { background-color: #4CAF50; color: white; } .dropdown:hover .dropdown-content { display: block; } </style> </head> <body> <nav class=”navbar”> <a href=”#” class=”active-link”>Tutorialspoint</a> <a href=”#”>Home</a> <div class=”dropdown”> <button class=”dropbtn”>Articles <i class=”fa fa-caret-down”></i> </button> <div class=”dropdown-content”> <a href=”#”>HTML</a> <a href=”#”>CSS</a> <a href=”#”>Bootstrap</a> </div> </div> <a href=”#”>Courses</a> </nav> <h1> Welcome to TutorialsPoint </h1> <h3> Simple Easy Learning at your fingertips </h3> </body> </html> CSS Fixed Navbar A fixed navbar is a navigation bar that sticks to the top of the screen when the user scrolls down the page. To make a navbar fixed, you can use the position: fixed property. Example <!DOCTYPE html> <html> <head> <style> body { margin: 0; font-family: Arial, sans-serif; height: 2000px; background-color: #e6e451; } .navbar { position: fixed; top: 0; width: 100%; margin: 0; padding: 0; overflow: hidden; background-color: #2c3e50; } .navbar a { display: block; float: left; color: #ecf0f1; text-align: center; padding: 14px 20px; text-decoration: none; font-size: 17px; transition: background-color 0.3s, color 0.3s; } .navbar a:hover { background-color: #34495e; color: #ecf0f1; } .active-link { background-color: #4CAF50; color: white; } .heading { padding-top: 70px; text-align: center; background-color: #e6e451; padding-bottom: 300px; } </style> </head> <body> <nav class=”navbar”> <a href=”#” class=”active-link”> Tutorialspoint </a> <a href=”#”>Home</a> <a href=”#”>Articles</a> <a href=”#”>Courses</a> </nav> <div class=”heading”> <h1> Welcome to TutorialsPoint </h1> <h2> Tutorialspoint CSS Fixed Navbar </h2> <h3>Scrolldown….</h3> </div> </body> </html> Divider Lines for Navbar You can also add a divider line between the links in

CSS – min-content

CSS – min-content Property ”; Previous Next The CSS min-content is a value that can be used for sizing properties to specify the minimum size of a box or element based on its content. It specifically suggests that text content will make use of soft-wrapping opportunities, which enable the material to resize to the length of its longest word. The min-content value is calculated based on the intrinsic minimum size required by the content inside the box. Syntax /* Used as a length */ width: min-content; inline-size: min-content; height: min-content; block-size: min-content; /* Used in grid tracks */ grid-template-columns: 100px 2fr min-content; CSS min-content – Box Sizing The following example demonstrates the use of min-content keyword for box sizing. <html> <head> <style> body { background-color: #b9cded; font-family: ”Helvetica Neue”, Arial, sans-serif; margin: 0; padding: 20px; } .container { width: 100%; display: flex; flex-direction: column; align-items: flex-start; } .item { width: min-content; background-color: #ffffff; padding: 5px; margin-bottom: 20px; border: 1px solid #e0e0e0; box-shadow: 0 3px 6px rgba(0, 0, 0, 1); color: #444444; border-radius: 8px; } </style> </head> <body> <div class=”container”> <div class=”item”>Min-Content Example.</div> <div class=”item”>Well-Crafted Min-Content Example.</div> <div class=”item”>Thoughtfully Presented Min-Content Example.</div> </div> </body> </html> CSS min-content – Sizing Grid Columns The following example demonstrates the use of min-content keyword for sizing grid columns. <html> <head> <style> body { margin: 0; font-family: ”Arial”, sans-serif; background-color: #f9f9f9; } #container { display: grid; grid-template-columns: 1fr min-content min-content; grid-gap: 15px; box-sizing: border-box; max-width: 800px; margin: 20px auto; padding: 20px; background-color: #f2f2f2; border: 1px solid #82807f; box-shadow: 0 4px 8px rgba(0, 0, 0, 0.5); border-radius: 8px; } .item { background-color: #5f9ea0; color: #141414; padding: 15px; border-radius: 5px; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.5); } </style> </head> <body> <div id=”container”> <div class=”item”>Flexible Content Area</div> <div class=”item”>Min-Content 1 Content Area</div> <div class=”item”>Min-Content 2 Content Area</div> <div class=”item”>Dynamic Content Area</div> <div class=”item”>Min-Content 3 Content Area</div> <div class=”item”>Min-Content 4 Content Area</div> </div> </body> </html> Print Page Previous Next Advertisements ”;

CSS – All

CSS – all ”; Previous Next The shorthand CSS property all resets all properties of an element, with the exception of unicode bidi, direction and CSS custom properties. It can reset properties to their original or inherited values or to the values explicitly defined in another cascade layer or in the stylesheet origin. Constituent Properties This property serves as a concise representation for all CSS properties, with the exception of unicode bidi, direction and CSS custom properties. The all property is specified with one of the global CSS keyword values. It is important to note that none of these values impact the unicode bidi and direction properties. Possible values The following is the list of possible values of all properties. initial – Indicates that all properties of the element should be reset to their initial values. inherit – Indicates that all properties of the element should be set to their inherited values. unset – Indicates that the element”s properties should set to inherited values in case of default inheritance, else to their initial values. revert – Specifies the behavior depending on the stylesheet origin associated with the declaration: If the rule is linked to the author”s origin, the revert value reverts the cascade to the user level and recalculates the specified values as if no author-level rules were applied to the element. In the context of revert, the author origin includes the override and animation origins. If the rule is part of the user origin, the value revert resets the cascade to the user agent level. This means that the specified values are calculated as if no rules were defined at author or user level for the element. If the rule originates from the user agent origin, the value revert behaves similarly to unset. revert-layer – Specifies the rollback of all properties of the element to a previous cascade layer, if available. This is still in experimental phase. If no other cascade layer is available, the properties of the element are reset to the matching rule in the current layer, if available, or to an earlier style origin. Syntax all = initial | inherit | unset | revert | revert-layer CSS all – Basic Example In the following example, the CSS all property is used to completely adjust all styling properties within specific elements. The first <div> with id=custom1 showcases the default styling without the all property, while subsequent <div> elements (custom2, custom3, and custom4) demonstrate the impact of all: inherit;, all: initial;, and all: unset; respectively. <html> <head> <style> html { font-size: x-large; color: #2c3e50; } #custom1 { background-color: #ecf0f1; color: #e74c3c; font-family: ”Verdana”, sans-serif; font-weight: bold; } #custom2 { background-color: #ecf0f1; color: #e74c3c; font-family: ”Verdana”, sans-serif; font-weight: bold; all: inherit; } #custom3 { background-color: #ecf0f1; color: #e74c3c; font-family: ”Verdana”, sans-serif; font-weight: bold; all: initial; } #custom4 { background-color: #ecf0f1; color: #e74c3c; font-family: ”Verdana”, sans-serif; font-weight: bold; all: unset; } </style> </head> <body> <p>No all property:</p> <div id=”custom1″>Hello from a creative and innovative universe!</div> <p>all: inherit:</p> <div id=”custom2″>Discover the virtually endless possibilities in your head.</div> <p>all: initial:</p> <div id=”custom3″>Welcome the start of an interesting new trip.</div> <p>all: unset:</p> <div id=”custom4″>Use the power of new ideas to realize your full potential.</div> </body> </html> Print Page Previous Next Advertisements ”;

CSS – Combinators

CSS – Combinators ”; Previous Next In CSS (Cascading Style Sheets), combinators are symbols or characters that specify the relationship between different HTML elements that you want to style. Combinators help you target elements based on their position and hierarchy within the HTML document. These combinators allow you to apply styles selectively based on the relationships between elements in your HTML structure, making your CSS more specific and targeted to achieve the desired styling effects. There are four main types of CSS combinators: Descendant Combinator (space) Child Combinator (>) Adjacent sibling Combinator (+) General sibling Combinator (~) CSS Combinators – Descendant Combinator (space) The descendant combinator, often represented by a single space (” “), selects elements that are descendants of specified element. If an element matches the second selector(descendant) and has an ancestor (parent, parent”s parent, etc.) that matches the first selector, then that element will be selected. For example, if you have an HTML structure like this: <div> <p>Paragraph 1</p> <p>Paragraph 2</p> </div> You can target all <p> elements inside the <div> like this: div p { /* CSS styles */ } The following code demonstrates the usage of the descendant combinator. In this example, we have a parent element <div> with the class name parent. Inside this parent element, we have multiple <p> elements. We will apply a some styles to the child elements with the class name child. <html> <head> <title>Descendant Combinator Example</title> <style> .parent { background-color: lightblue; padding: 20px; } .parent p { color: red; font-weight: bold; } </style> </head> <body> <div class=”parent”> <h1>This is the parent element</h1> <p>This is a paragraph inside the parent element.</p> <p>This is a paragraph inside the parent element.</p> </div> <div> <p>This is a paragraph outside the parent element.</p> </div> </body> </html> CSS Combinators – Using List The following example demonstrates the usage of the descendant combinator for list elements. <html> <head> <title>Descendant Combinator Example</title> <style> div ul { background-color: lightblue; padding: 10px; } div ul li { color: white; margin-bottom: 5px; } </style> </head> <body> <div> <h2>Fruits</h2> <ul> <li>Apple</li> <li>Banana</li> <li>Orange</li> </ul> </div> </body> </html> CSS Combinators – Child Combinator (>) The child combinator, represented by the greater-than symbol (>), selects all elements that are immediate children of a specified element. Using the same HTML structure as above, you can target only the immediate child <p> elements like this: div > p { /* CSS styles */ } The following example demonstrates the usage of the child selector(>). In this example, we have a parent element <div> with the class name parent. Inside the parent element, we have multiple <p> elements. We want to apply a specific style to the child elements with the class name child. <html> <head> <title>Child Combinator Example</title> <style> .parent > .child { color: blue; } </style> </head> <body> <div class=”parent”> <p>This is the parent element.</p> <p class=”child”>This is the first child element.</p> <p class=”child”>This is the second child element.</p> <p>This is the third child element.</p> <p>This is the fourth child element.</p> </div> <div> <p>This is another paragraph.</p> </div> </body> </html> The following example demonstrates how the child combinator selector can be used to target specific elements that are direct children of a parent element, allowing for more precise styling and customization. <html> <head> <title>Child Combinator Example</title> <style> div > span { color: red; } ul > li { font-weight: bold; } </style> </head> <body> <div> <span>This text will be red.</span> <span>This text will not be affected.</span> </div> <ul> <li>This list item will have bold font-weight.</li> <li>This list item will also have bold font-weight.</li> </ul> </body> </html> CSS Combinators – Adjacent sibling Combinator (+) The adjacent sibling combinator, represented by the plus sign (+), selects an element that is immediately preceded by a specified element. For example, if you have the following HTML: <h2>Heading 1</h2> <p>Paragraph 1</p> <h2>Heading 2</h2> <p>Paragraph 2</p> You can target the <p> element that directly follows a <h2> like this: h2 + p { /* CSS styles */ } The following code demonstrates the usage of the adjacent sibling selector(+). In this example we are targeting the paragraphs that directly follow <h2> elements. <html> <head> <style> h2 + p { color: red; } </style> </head> <body> <div> <h2>Example of Adjacent Sibling Combinator</h2> <p>This is the first paragraph.</p> <p>This is the second paragraph.</p> </div> <div> <p>This is the third paragraph.</p> <p>This is the fourth paragraph.</p> </div> </body> </html> Here is another example demonstrating the usage of the adjacent sibling selector(+). div + span: This selects the span element that immediately follows a div element. It sets the color of the span text to red. span + button: This selects the button element that immediately follows a span element. It sets the background color of the button to yellow. button + ul: This selects the ul element that immediately follows a button element. It changes the list-style-type of the unordered list to square bullets. <html> <head> <style> div + span { color: red; } span + button { background-color: yellow; } button + ul { list-style-type: square; } </style> </head> <body> <div>This is a div element.</div> <span>This is a span element.</span> <button>This is a button element.</button> <ul> <li>List item 1</li> <li>List item 2</li> <li>List item 3</li> </ul> </body> </html> CSS Combinators – General sibling Combinator (~) TThe general sibling combinator, represented by the tilde symbol (~), selects all elements that are siblings of a specified element. It”s similar to the adjacent sibling combinator but doesn”t require elements to be immediately adjacent. For instance: <h2>Heading 1</h2> <p>Paragraph 1</p> <h2>Heading 2</h2> <p>Paragraph 2</p> You can target all

CSS – Order

CSS – Order ”; Previous Next What is an order? CSS order property is used to specify the order in which flex items appear within a flex container. The order of the flex items is determined by the values of their order property. The flex items with the lower order value will be displayed first. Here are some additional things to keep in mind: The order property is not inherited by child elements. The order property only affects flex items. The default value of the order property is 0. Following are all possible values that can be used for property order: integer: Represents the ordinal group to be used by the item. inherit: Uses the same value of its parent. initial: The element uses default value i.e 0. CSS Order Integer The CSS order property is set to an integer value. The value of the order property can be any positive or negative integer. We can use order property with positive integer value. A positive value means that the item with the highest positive order value will be displayed last. Example Here is an example − <html> <head> <style> .my_flex_container { display: flex; background-color: #0ca14a; height: 90px; } .my_flex_container div { background-color: #FBFF22; padding: 10px; margin: 10px; height: 50px; text-align: center; } </style> </head> <body> <div class=”my_flex_container”> <div style=”order: 2″>Item 1</div> <div style=”order: 6″>Item 2</div> <div style=”order: 4″>Item 3</div> <div style=”order: 1″>Item 4</div> <div style=”order: 3″>Item 5</div> <div style=”order: 5″>Item 6</div> </div> </body> </html> The CSS order property can be set to a negative integer value. A negative value means that the items with the highest negative order value will be displayed first. Example Here is an example − <html> <head> <style> .my_flex_container { display: flex; background-color: #0ca14a; height: 90px; } .my_flex_container div { background-color: #FBFF22; padding: 10px; margin: 10px; height: 50px; text-align: center; } </style> </head> <body> <div class=”my_flex_container”> <div style=”order: 4″>Item 1</div> <div style=”order: 6″>Item 2</div> <div style=”order: -3″>Item 3</div> <div style=”order: 1″>Item 4</div> <div style=”order: -5″>Item 5</div> <div style=”order: 2″>Item 6</div> </div> </body> </html> CSS Order Initial The order: initial value simply sets the order property of the item back to its initial value, which is usually 0. Example Here is an example − <html> <head> <style> .my_flex_container { display: flex; background-color: #0ca14a; height: 90px; } .my_flex_container div { background-color: #FBFF22; padding: 10px; margin: 10px; height: 50px; text-align: center; } </style> </head> <body> <div class=”my_flex_container”> <div style=”order: 5″>Item 1</div> <div style=”order: 3″>Item 2</div> <div style=”order: 1″>Item 3</div> <div style=”order: 6″>Item 4</div> <div style=”order: initial”>Item 5</div> <div style=”order: 4″>Item 6</div> </div> </body> </html> CSS Order Unset If you set the order property to unset value, the flex item will be displayed in it”s default orde based on the HTML markup. Example Here is an example where order property is set to unset to the flex item 3. Then order of the flex item 3 will be displayed in the default order − <html> <head> <style> .my_flex_container { display: flex; background-color: #0ca14a; height: 90px; } .my_flex_container div { background-color: #FBFF22; padding: 10px; margin: 10px; height: 50px; text-align: center; } </style> </head> <body> <div class=”my_flex_container”> <div style=”order: 2″>Item 1</div> <div style=”order: 4″>Item 2</div> <div style=”order: unset”>Item 3</div> <div style=”order: 1″>Item 4</div> <div style=”order: 3″>Item 5</div> <div style=”order: 5″>Item 6</div> </div> </body> </html> CSS Order Revert When we set the order property to the revert value, the flex item will be displayed in the order it appears in the HTML markup, but with the order reversed. Example Here is an example where Order property is set to revert for the fifth flex-item. Then order of the fifth flex-item will be reversed, so it will be displayed first − <!DOCTYPE html> <html> <head> <style> .my_flex_container { display: flex; background-color: #0ca14a; height: 90px; } .my_flex_container div { background-color: #FBFF22; padding: 10px; margin: 10px; height: 50px; text-align: center; } </style> </head> <body> <div class=”my_flex_container”> <div style=”order: 5″>Item 1</div> <div style=”order: 3″>Item 2</div> <div style=”order: 1″>Item 3</div> <div style=”order: 6″>Item 4</div> <div style=”order: revert”>Item 5</div> <div style=”order: 4″>Item 6</div> </div> </body> </html> Print Page Previous Next Advertisements ”;