Found 2202 Articles for HTML

What are the implications of using "!important" in CSS?

AmitDiwan
Updated on 06-Dec-2022 09:49:22

174 Views

The !important rule overrides all previous styling rules. It is based on the concept of priority or specificity. The !important rule provides a way to make your CSS cascade. It also includes the rules that are to be applied always. A rule having the !important property will always be applied, no matter where that rule appears in the CSS document. Let us see an example − Priority - Without Using !important Example Let us first see an example how the specificity and priority works without using the !important − ... Read More

How to center a "position: absolute" element?

AmitDiwan
Updated on 06-Dec-2022 09:46:14

1K+ Views

We can easily center an absolute position element horizontally and vertically in Python. For that, use the following CSS properties. For horizontal center, use the following properties − left margin-left For vertical center, use the following properties − top margin-top Horizontal center an absolute position element Example To horizontal center an absolute position element, use the following code − div.center{ width:200px; height: 50px; ... Read More

How to create a responsive custom scrollbar using CSS?

AmitDiwan
Updated on 05-Dec-2022 12:21:24

582 Views

To create a custom scrollbar, we will use the following pseudo element to create a responsive custom scrollbar using CSS − :-webkit-scrollbar Create a custom scrollbar First, set the width of the scrollbar − ::-webkit-scrollbar { width: 12px; } Set the color of the scrollbar − ::-webkit-scrollbar-thumb { background: skyblue; } Set the hover color of the scrollbar − ::-webkit-scrollbar-thumb:hover { background: blue; } Example Let us now see the complete example to create a responsive custom scrollbar − ... Read More

How to make horizontal line with words in the middle using CSS?

AmitDiwan
Updated on 05-Dec-2022 12:11:43

3K+ Views

With CSS, we can make horizontal line with words in the middle. Additionally, we can also make horizontal line with headings and even image. Let us see some examples − Make a horizontal line with words in the middleExample In this example, we will create a horizontal line with words in the middle using flex − p { display: flex; flex-direction: row; } ... Read More

Is wrapping a div inside an anchor tag valid code?

AmitDiwan
Updated on 05-Dec-2022 11:54:29

7K+ Views

Yes, according to HTML5 Specifications, we can place a div inside an anchor tag, for example − Another example − this now becomes a link The HTML5 allows tag to be wrapped around a element. Therefore, the will be visible inside the tag.Example Let us see an example for div inside the tag − .container { position: relative; background-color: orange; width: 200px; height: 200px; } .container a { position: absolute; top: 0; bottom: 0; left: 0; right: 0; z-index: 999; } Demo Heading div one div two Output Click on the orange colored div and the link will open −

jQuery Data vs Attr?

AmitDiwan
Updated on 05-Dec-2022 11:51:30

2K+ Views

The data() in jQuery is used to fetch the value of any custom data attribute from the matched HTML element(s). The jQuery attr() method is used to fetch the value of any standard attribute from the matched HTML element(s). Let us see the differences − The .attr() method includes DOM Manipulation and gets the data from the current HTML or change the HTML code if used to change an attribute value. The .data() method does not include DOM manipulation and gets the data from the internal cache and will change that data if a set is called. The .data() ... Read More

How to remove HTML Tags with RegExp in JavaScript?

AmitDiwan
Updated on 22-Nov-2022 06:47:35

2K+ Views

The regex will identify the HTML tags and then the replace() is used to replace the tags with null string. Let’s say we have the following HTML − The tags stripped...)/ig, ''); } The call for the above function to remove tags goes like this − document.write(removeTags('The tags stripped...

How to strip out HTML tags from a string using JavaScript?

AmitDiwan
Updated on 22-Nov-2022 06:44:33

809 Views

We can strip out HTML tags from a string with JavaScript using the following examples − Strip out HTML tags using Regex Strip out HTML tags using InnerText Strip out HTML tags using Regex The regex will identify the HTML tags and then the replace() is used to replace the tags with null string. Let’s say we have the following HTML − The tags stripped...)/ig, ''); } The call for the above function to remove tags goes like this − document.write(removeTags('The tags stripped...

How to Detect User Timezone in PHP?

AmitDiwan
Updated on 22-Nov-2022 06:26:55

6K+ Views

To detect timezone, we can either set a timezone and display or we can directly display. Here, we will see two examples − Get and Display the default timezone. Set a Timezone and Display it. Get the Default TimeZone To get the default timezone in PHP, we will use the following method − date_default_timezone_get(); Example Let us see the example − Output Default TimeZone:UTC Set a TimeZone and Display In this example, we will first set a timezone using the following method − date_default_timezone_set To get the timezone we have ... Read More

How to Detect User Timezone in JavaScript?

AmitDiwan
Updated on 13-Sep-2023 04:03:31

49K+ Views

To detect the user timezone with the name of the timzone itself, use the Internationalization API. This gives the name of the Timezone in which the user and the browser is being worked on. Detect Exact Timezone with Name Example To get the exact timezone name, we will use the Internationalization API − DOCTYPE html> Timezone document.getElementById("test").innerHTML = Intl.DateTimeFormat().resolvedOptions().timeZone; Output Get the Timezone (Difference between UTC ... Read More

Advertisements