Found 8894 Articles for Front End Technology

Setting Tab Sizes in HTML with CSS tab-size Property

AmitDiwan
Updated on 27-Dec-2023 16:19:55

464 Views

CSS tab-size property allows us to set the amount of whitespace used in tabs. The width of the tab character can be customized easily. The value set for the tab size is in spaces. Let us see the syntax. Syntax tab-size: value; The value above is the number value set for tab space. The following examples illustrate the CSS tab-size property. Example Here, we have set the tab size to 32 using the tab-size property − tab-size: 32; The tab size for the firefox is also set − -moz-tab-size: 32; Let us see ... Read More

Change Cursor Color with CSS caret-color

AmitDiwan
Updated on 30-Oct-2023 14:37:25

756 Views

The cursor can be easily changed in CSS. For that, use the caret-color property. This will allow you to change the color in textarea, input, etc. The following examples illustrate the CSS caret-color property to change the cursor color on a web page. Change the Cursor Color of the Input Element The input is the field where data is entered by the user. To change the cursor color, the is set with the caret-color property − input { font-size: 3em; caret-color: chartreuse; margin: 2%; } Here is ... Read More

Controlling Whether Mouse & Touch Allowed with CSS pointer-events Property

AmitDiwan
Updated on 12-Mar-2021 11:06:24

177 Views

Using the CSS pointer-events property we can control whether a mouse and touch are allowed on an element.The syntax of CSS pointer-events property is as follows −pointer-events: auto|none;Above, auto is default. Element reacts to pointer events, whereasnone: Element does not react to pointer eventsExampleThe following examples illustrate CSS pointer-events property. Live Demo a {    margin: 10vh;    pointer-events: none; } a:last-of-type {    pointer-events: auto; } No pointer event here Automatic pointer event here OutputThis will produce the following result −Example Live Demo select {    margin: 10vh;    pointer-events: none; ... Read More

Disabling Scroll Anchoring with CSS

AmitDiwan
Updated on 01-Nov-2023 16:54:54

409 Views

To disable the default scroll anchoring provided by web browsers, we can use the overflow-anchor property. To disable scroll anchoring, set the overflow-anchor property to none − body { overflow-anchor: none; } To enable the scroll anchoring, set the value to auto that is also the default value. However, scroll anchoring behavior is enabled by default in any web browser. Disable Scroll Anchoring Let us see the example to disable scroll anchoring − Example body { ... Read More

Using Data-Attributes (data-*) in CSS

AmitDiwan
Updated on 12-Mar-2021 11:02:47

961 Views

We can store extra information about elements using data-* attribute. The following examples illustrate CSS data-* attribute.Example Live Demo dl {    margin: 2%; } p {    width: 60%;    background-color: lightgreen;    padding: 2%;    color: white;    text-align: center; } dt {    font-weight: bold; } dt:hover {    cursor: pointer; } dd {    font-style: italic; } Tea Hot Spicy Tea or Ice Lemon Tea Toast Hot Garlic Butter Toast (hover over food item) function showDescription(food) {    let foodType = food.getAttribute("data-food-type");    document.querySelector('p').textContent = ("We ... Read More

Get and Set CSS Variables with JavaScript

AmitDiwan
Updated on 02-Nov-2023 11:56:21

12K+ Views

To get and set the variables with JavaScript, we can use various methods. The getComputedStyle() method gives an object which includes all the styles applied to the target element. The getPropertyValue() method is used to obtain the desired property from the computed styles. The setProperty() is used to change the value of CSS variable. The following example illustrate how we can get and set CSS variables using JavaScript. First, we have called the two custom methods − The showColor() method use the getPropertyValue() method to get the property − function showColor() { let ... Read More

Using CSS :placeholder-shown to Customize Styles for Empty Text Input

AmitDiwan
Updated on 02-Jan-2024 19:08:16

223 Views

To customize the style for the input textbox having a placeholder, we use the :placeholder-shown pseudo-class of CSS. Placeholder text is a hint for the user to understand what is to be typed in the input text field. The following examples illustrate CSS :placeholder-shown pseudo-class. Set the border for the text field The border for the text field is set using the border-color property. Place it inside the placeholder-shown pseudo-class as shown below − input:placeholder-shown { border-color: dodgerblue; } Example Let us see the example − ... Read More

How to Create a Checkmark / Tick with CSS

AmitDiwan
Updated on 12-Mar-2021 10:53:39

3K+ Views

We can create a customized checkmark using CSS. The following examples illustrate this effect −Example Live Demo div {    margin: 2%;    position: relative;    width: 40px;    height: 40px;    box-shadow: inset 0 0 12px lightblue; } div::before {    content: "";    position: absolute;    width: 8px;    top: 50%;    height: 50%;    border-radius: 2px;    background-color: rgb(123, 45, 20);    transform: translateX(12px) rotate(-45deg);    transform-origin: left bottom;    z-index: +1; } div::after {    content: "";    position: absolute;    bottom: 0;    height: 8px;    width: 100%;    border-radius: 2px;    background-color: rgb(200, ... Read More

How to Change Placeholder Color for Textboxes in CSS?

AmitDiwan
Updated on 16-Nov-2023 14:54:20

960 Views

Use the ::placeholder pseudo-element, we can change the placeholder text color for textboxes. Also, use the :last-child pseudo class for the form input. Syntax The syntax of CSS ::placeholder pseudo-element is as follows − ::placeholder { attribute: /*value*/ } Default Placeholder Example Let us first see how a default placeholder color looks like − Fill the form First Name Placeholder With a Different Color ... Read More

Difference Between Pseudo-Class and Pseudo-Element in CSS

AmitDiwan
Updated on 01-Nov-2023 16:12:14

3K+ Views

Pseudo-Class A pseudo-class represents a state of a selector like :hover, :active, :last-child, etc. These start with a single colon(:). Syntax The syntax of CSS pseudo-class is as follows − :pseudo-class{ attribute: /*value*/ } Pseudo-Element Similarly, a pseudo-element is used to select virtual elements like ::after, ::before, ::first-line, etc. These start with a double colon(::). Syntax The syntax of CSS pseudo-element is as follows − ::pseudo-element{ attribute: /*value*/ } Change the Link on Hover The following example illustrate changing the link on hover using the CSS pseudo class − Example ... Read More

Advertisements