Can Love Be Taxed? Gifts, Marriage & "Spouse" under the Income-tax Act, 2025 | Finedge by EduLaw
EduLaw EditorialCitizen's PlaybookA citizen-friendly and lawyer-useful explainer on how the Income-tax Act, 2025 taxes gifts, the ₹50,000 threshold, the relative and marriage-occasion exemptions, and why the word
Finedge by EduLaw Legal & Financial Explainers for Citizens Citizen Rights Edition · Updated 07 July 2026 Finedge by EduLaw | Citizen Rights Edition | Updated: 07 July 2026 Can Love Be Taxed? How Indian tax law treats gifts, marriage and the word "spouse" under the Income-tax Act, 2025. A wedding gift is rarely just a gift in the eyes of the taxman. It is money, a relationship, and a legal category — all at once. This explainer walks through exactly where the line falls, and why that line gets complicated for couples the law does not yet recognise as married. INCOME-TAX ACT, 2025 "spouse" ₹50,000 the gift the statute Table of Contents Quick Answer Why This Matters The Core Gift-Tax Rule What Counts as an Exemption? Why "Spouse" is Central Constitutional Background Realistic Examples Petitioners vs Revenue What This Could Change Practical Takeaways Myth vs Reality Glossary FAQ Conclusion Sources Direct Answer Quick Answer In India, certain gifts can become taxable in the recipient's hands if they cross the statutory threshold and do not fall within an exemption. Money received without consideration is generally taxed as "income from other sources" once the aggregate value in a year exceeds ₹50,000 — and if that limit is crossed, the entire amount becomes taxable, not just the excess. Gifts from persons falling within the statutory definition of "relative" — which expressly includes a spouse — are generally exempt regardless of amount. Gifts received on the occasion of an individual's own marriage are also generally exempt, as a separate rule. The controversy for same-sex partners arises because Indian law does not currently recognise same-sex marriage. Since these exemptions are written using the words "spouse" and "marriage", a same-sex partner may not automatically qualify, even where the relationship is real, long-standing and publicly acknowledged. Framing the Issue Why This Matters It would be a mistake to read this as merely a technical tax question about thresholds and exemption clauses. At its heart, this is a question about whether the law sees a partner as family or as a legal stranger. When a statute uses the word "spouse", it is not describing a feeling — it is drawing a boundary. Everyone inside that boundary gets a certain fiscal, legal or administrative benefit; everyone outside it does not, however close the relationship may be in fact. That boundary sits at the intersection of tax law, constitutional equality, personal dignity and the ordinary rules of statutory interpretation, and it is precisely because so many different legal fields meet at this one word that a gift-tax dispute can quietly become a much larger conversation about recognition. The path from a private relationship to a fiscal benefit is not a single step. It runs through several stages, and Indian law currently allows a couple to complete some of these stages while leaving others incomplete. Decriminalisation → Relationship → Marriage Recognition → Fiscal Benefits → Tax Treatment For same-sex couples in India, the ladder currently stops at "Relationship" — the step of "Marriage Recognition" has not been completed under existing law, which is why the later steps remain uncertain. The Statutory Position The Core Gift-Tax Rule The Income-tax Act, 2025, which came into force from 1 April 2026 and replaced the Income-tax Act, 1961, carries forward — in a reorganised and simplified form — the long-standing principle that certain gifts are not entirely free of tax consequences merely because no money changed hands "for" anything. The rule, in essence, treats specified categories of unrequited receipts as deemed income in the hands of the person who receives them, taxable under the head "income from other sources", unless a specific statutory exemption applies. Three broad categories of receipt attract this rule. The first is money received without consideration, such as a cash gift or a bank transfer with no corresponding service or sale behind it. The second is immovable property — land or a building — received without consideration or for a price that is inadequate compared to its stamp-duty value. The third is specified movable property, such as shares, securities, jewellery, artworks, bullion or virtual digital assets, received without consideration or for less than its fair market value. Each category has its own valuation mechanics, but the animating idea is the same: if you receive value without paying for it, and the value crosses a threshold, the law treats that value as your income for the year. The ₹50,000 Threshold For money gifts, the touchstone figure is ₹50,000. If the aggregate value of monetary gifts received without consideration during the financial year exceeds this figure, the whole aggregate amount — not just the portion above ₹50,000 — becomes chargeable to tax under "income from other sources". This aggregation is done across all such receipts during the year, not gift by gift. Aggregate, Not Transaction-Wise A common misunderstanding is to check each individual gift against the ₹50,000 mark. The law instead looks at the sum total of qualifying monetary gifts received in the year. ₹20,000 from one person and ₹40,000 from another, both without consideration and both from non-relatives, add up to ₹60,000 — and become fully taxable, even though neither individual gift alone crossed the line. ₹50,000 is not just a number. It is the line between ignored and taxable — unless an exemption applies. It is worth being precise about the consequence of crossing the threshold: the law does not tax only the amount above ₹50,000, the way certain slab-based calculations work elsewhere. Once the aggregate crosses the threshold, the entire aggregate sum is added to the recipient's income for the year under "income from other sources", and taxed at the recipient's applicable slab rate. This is precisely why the threshold functions less like a tax-free allowance and more like a trigger — cross it, and the whole amount is swept in. Escaping the Charge What Counts as an Exemption? Not every gift that crosses ₹50,000 ends up taxed. The statute carves out specific, clearly defined situations where the deemed-income rule does not apply at all, regardless of the amount involved. For the purposes of this discussion, two exemptions matter the most, and it is important to keep them conceptually separate because they operate on different logic. Card 1 — The Relative Exemption Gifts received from a person who falls within the statutory definition of "relative" are generally exempt from tax, irrespective of the amount gifted. For an individual, this definition is drawn narrowly and specifically: it includes the individual's spouse, parents and other lineal ascendants, children and other lineal descendants, siblings of the individual, siblings of the individual's spouse, siblings of the individual's parents, and the spouses of all these relatives. A spouse is thus not merely "included" as an afterthought — the spousal relationship sits at the very centre of the relative definition, and many of the other listed relatives are defined by reference to the spouse (such as the spouse's siblings or the spouse's lineal ascendants). The important point for citizens is that not every emotionally close person is a "relative" for tax purposes. A best friend of thirty years, a mentor, a devoted caregiver, or a long-term partner outside a legally recognised marriage does not fit within this list, however central they may be to one's life. The exemption tracks a defined legal category, not a felt sense of closeness. Card 2 — The Marriage-Occasion Exemption Separately, gifts received by an individual on the occasion of that individual's own marriage are generally exempt from tax, regardless of the amount and regardless of who the donor is — relative or otherwise. This exemption exists because Indian society traditionally treats wedding gifts as customary and occasion-specific, not as ordinary income. This exemption is conceptually distinct from the relative exemption. It does not depend on the donor being a relative at all; a stranger's wedding cash gift can be exempt under this head. What it does depend on is the existence of a marriage — meaning a marriage that the law recognises as such. The exemption is tied to a legal event, and this is exactly where the difficulty begins for couples whose relationship the law does not yet recognise as a marriage: without a legally recognised marriage, this specific exemption may simply have no occasion to attach itself to. The Pivot Point Why "Spouse" Becomes the Centre of the Dispute Tax statutes are drafted using precise, closed legal categories rather than open, descriptive language. This is by design — a tax authority needs a bright-line test to administer exemptions consistently across millions of taxpayers, and "relative" or "spouse" gives it exactly that: a category that can be verified against a marriage certificate, a birth certificate, or a family register, rather than against the depth of someone's affection. The cost of this precision is that words like "partner", "companion" or "significant other" — however accurately they may describe a real relationship — are simply not interchangeable with "spouse" unless the law itself recognises the relationship as a marriage. For a heterosexual married couple, this rarely causes friction, because the marriage is legally recognised under the Hindu Marriage Act, the Special Marriage Act, the Indian Christian Marriage Act, personal laws, or other applicable statutes, and the spouse automatically falls within the "relative" definition for tax purposes. For a same-sex couple, the relationship may be loving, stable, publicly known and long-standing, but because Indian law does not currently treat it as a marriage under any of these statutes, the partner may not be treated as a "spouse" — and therefore not as a "relative" — for the purposes of the gift-tax exemption. Recognised Spouse → Falls within the statutory "relative" definition. → Relative exemption is generally available. → Gifts between the couple, of any amount, are generally not taxed as income. Unrecognised Partner → Does not fall within the statutory "relative" definition. → May be treated as a non-relative for tax purposes. → Gifts above the threshold may be taxable, subject to facts and any other applicable exemption. Reading the Case Law Correctly Constitutional Background To understand why this gap exists, it helps to be precise about what India's constitutional courts have actually decided — and, just as importantly, what they have not decided. 2018 — Navtej Singh Johar v Union of India A Constitution Bench of the Supreme Court unanimously read down Section 377 of the Indian Penal Code to the extent that it criminalised consensual sexual conduct between adults of the same sex. The Court grounded its reasoning in the constitutional guarantees of dignity, privacy and equality, holding that criminalising consensual same-sex intimacy violated these fundamental rights. What this judgment achieved was decriminalisation — it removed a criminal prohibition and affirmed constitutional dignity for LGBTQ+ persons. It did not, however, create any new civil status, and it did not extend marriage recognition to same-sex couples. 2023 — Supriyo v Union of India A five-judge Constitution Bench of the Supreme Court considered a batch of petitions seeking recognition of same-sex marriage, including a request to read the Special Marriage Act, 1954 in a gender-neutral manner. The Bench held, in substance, that there is no unqualified fundamental right to marry that could be enforced through the courts in this manner, and it declined to read same-sex marriage into the existing statutory framework. The Court left the question of legislative recognition of same-sex unions to Parliament and the policy domain, while making certain observations regarding the dignity and lived realities of queer relationships. The key legal takeaway is unambiguous: decriminalisation under Navtej is not the same thing as marriage recognition, and Supriyo confirmed that the latter has not occurred through judicial pronouncement. 2026 — The Income-tax Act, 2025 Context Against this constitutional backdrop, the Income-tax Act, 2025 continues to use words such as "spouse", "marriage" and "relative" in provisions governing gift taxation. Because these words carry defined legal meanings tied to recognised marriage, the absence of same-sex marriage recognition under Indian law continues to shape how tax exemptions apply — irrespective of how settled and committed a same-sex relationship may be in fact. Applying the Law Realistic Examples The following illustrations use fictional names and facts purely to show how the rules interact. Tap each example to expand it. Example 1 — Cash Gift to a Partner Facts: Aarav transfers ₹5,00,000 to Karan by bank transfer to help pay for medical treatment. The two have been life partners for several years but are not married under any law recognised in India. Because Karan is not Aarav's legally recognised spouse, Karan does not fall within the statutory "relative" definition in relation to Aarav. If no other exemption applies, the ₹5,00,000 received without consideration would ordinarily be treated as Karan's income from other sources, since it comfortably exceeds the ₹50,000 aggregate threshold. Had the law treated Aarav and Karan as legally married spouses, the relative exemption would ordinarily have applied in full, regardless of amount, and no tax would arise on this transfer at all. The outcome here turns entirely on legal status and statutory classification — not on the genuineness of the relationship, the reason for the gift, or the depth of the affection involved. Example 2 — Wedding Gifts at a Legally Recognised Wedding Facts: At a wedding solemnised under a marriage law recognised in India, guests give the couple cash envelopes and jewellery totalling several lakh rupees, including gifts from friends who are not "relatives" under the statutory definition. Because these gifts are received on the occasion of the individual's own marriage — a legally recognised marriage — the marriage-occasion exemption generally applies to the entire value, regardless of the amount and regardless of whether the donor is a relative or a friend. This exemption is available precisely because the underlying event is a marriage the law acknowledges as such. The same generosity extended at a commitment ceremony or celebration that is not a legally recognised marriage would not automatically attract this exemption, because the exemption is anchored to the legal event, not merely the social occasion. Example 3 — One Partner Transfers Property to Another Facts: One partner transfers a flat, or a substantial quantity of jewellery, to the other without receiving anything in return. Here the analysis depends on the nature of the asset. For immovable property received without consideration, the stamp-duty value is compared against the ₹50,000 threshold; for specified movable property such as jewellery, the fair market value is used. If the recipient is treated as a "relative" — as would ordinarily be the case for a legally married spouse — the relative exemption would generally apply and no tax would arise on receipt. If the recipient is not treated as a relative, the value may be taxable as deemed income, subject to valuation rules. It is also worth flagging that stamp duty, registration requirements and other property-law formalities operate independently of the income-tax analysis and may separately affect the transaction, regardless of how the income-tax question is resolved. The Legal Tension Petitioners' Argument vs Revenue's Argument Where a same-sex partner is denied a marriage-linked or spouse-linked tax benefit, two coherent legal positions can be constructed. Setting them out side by side helps clarify what is actually being argued, and why the dispute is genuinely difficult rather than one-sided. Petitioners May Argue Same-sex partners in committed relationships are, in substance, taxed as legal strangers to one another, despite the reality and permanence of the relationship. Fiscal benefits tied to marriage or spousal status create differential treatment between couples who can marry and couples who currently cannot under Indian law. Where the law itself prevents a couple from marrying, denying them benefits that flow only from marriage may raise concerns under the equality guarantees recognised in Navtej and related jurisprudence. Tax law, being a practical and revenue-focused branch of law, should not entirely ignore lived, verifiable relationships merely because they fall outside a specific statutory label. Revenue May Argue The statute uses precisely defined legal terms such as "spouse" and "relative", and administrable tax law depends on such bright-line definitions. Courts interpreting a taxing statute cannot rewrite "spouse" to mean "partner" through interpretation alone; that would amount to legislating a new class of relationship, not interpreting an existing one. Without a marriage recognised under existing marriage law, a tax exemption tied expressly to marriage or spousal status cannot be extended automatically to a relationship the law has not classified as a marriage. Any wider reform recognising same-sex partnerships for tax and other purposes is a matter better suited to legislative action than to case-by-case adjudication. This section explains the legal tension on both sides of the argument. It does not claim that any court has finally and definitively resolved this specific gift-tax question for same-sex partners. As of this update, this remains, in EduLaw's assessment, a pending issue and an open question — one that is subject to future judicial determination, administrative clarification, or legislative reform, rather than a settled legal position. Looking Ahead What This Issue Could Change If a future ruling, clarification or legislative amendment were to address the treatment of same-sex partners under the gift-tax provisions, several downstream areas could potentially be affected. These include the direct question of gift taxation between same-sex partners, the broader interpretation of other marriage-linked fiscal benefits scattered across tax and financial law, the trajectory of future equality litigation on partner-benefit recognition, and the pace at which insurance, pension, inheritance and housing frameworks are asked to confront similar recognition gaps. At the same time, it is important not to overstate what a narrow tax outcome could achieve. A favourable ruling on a specific gift-tax exemption would not, by itself, amount to the legal recognition of same-sex marriage across all Indian statutes. Tax decisions are typically confined to the fiscal provision actually in dispute, and a decision favourable to a taxpayer in one case does not automatically rewrite the definition of "spouse" or "marriage" everywhere else in Indian law — in family law, succession law, adoption law or elsewhere. Broader reform of that kind would most likely require either a considered legislative intervention by Parliament or a separate line of constitutional litigation squarely addressing marriage recognition, of the kind Supriyo left open rather than closed. Practical Guidance Practical Takeaways For Citizens Keep clear records of every gift received — bank statements, dates, and the identity of the donor — especially once amounts start approaching ₹50,000 in aggregate for the year. Remember the ₹50,000 threshold is checked in aggregate for the year for monetary gifts, not gift by gift. Do not assume that emotional closeness automatically translates into a tax exemption; the exemption depends on a defined legal relationship or a legally recognised occasion. Understand that wedding gifts and partner-support gifts are treated very differently in law, even if they feel similar in spirit. For Lawyers Frame any such dispute as sitting at the intersection of statutory interpretation, constitutional equality and fiscal classification, rather than as a pure tax technicality or a pure rights case alone. Be precise and conservative about the relief sought; conflating a request for a specific fiscal exemption with a request for marriage recognition weakens both arguments. Avoid overstating the current state of the law — do not represent to a client or a court that same-sex marriage is recognised in India when it is not. Clearly distinguish decriminalisation (Navtej) from recognition (the unresolved question after Supriyo) in every submission and client note. For Tax Professionals Always check the precise donor-recipient relationship against the statutory "relative" definition before assuming an exemption applies. Verify the occasion claimed for any marriage-occasion exemption, and confirm that the underlying marriage is legally recognised. Compute the aggregate value of monetary gifts received in the year, not merely the value of the transaction under review. Identify the correct asset type — money, immovable property, or specified movable property — since each carries its own valuation and threshold mechanics. Document the specific exemption being claimed and retain supporting evidence in the client file. For Policymakers Fiscal statutes would benefit from greater clarity on how committed partnerships outside legally recognised marriage are to be treated, rather than leaving the question to be resolved indirectly through interpretation. Tax law frequently exposes gaps that originate in family law; a fiscal dispute is often a symptom of an unresolved recognition question elsewhere in the legal system. Similar recognition disputes recur across taxation, inheritance, insurance, pension and housing law, suggesting that a coordinated legislative approach may be more effective than piecemeal, sector-by-sector fixes. Common Misunderstandings Myth vs Reality Myth Reality "Any gift from someone I love is tax-free." Tax law uses defined legal categories such as "relative" and "spouse", not emotional closeness. Affection alone does not create an exemption. "Below ₹50,000 always means no issue." For monetary gifts, the threshold is checked in aggregate across the whole financial year, not per transaction, and the facts of each case still matter. "Same-sex relationships are illegal in India." Consensual same-sex relations between adults were decriminalised by the Supreme Court in Navtej Singh Johar v Union of India in 2018. "Decriminalisation means marriage recognition." Supriyo v Union of India in 2023 did not read same-sex marriage into existing marriage laws; decriminalisation and marriage recognition remain legally distinct. "A tax ruling can legalise same-sex marriage." A tax ruling, even a favourable one, would typically affect a specific fiscal benefit only; wider marriage reform remains a separate legislative or constitutional question. Plain-Language Definitions Mini Glossary Gift Money, immovable property, or specified movable property received without consideration or for inadequate consideration. Relative A statutorily defined category of persons — including spouse, parents, children, siblings and certain in-laws — whose gifts to an individual are generally exempt from tax regardless of amount. Spouse A husband or wife under a marriage legally recognised in India; a term that anchors much of the "relative" definition and several fiscal exemptions. Marriage-Occasion Exemption A separate rule exempting gifts received by an individual on the occasion of that individual's own legally recognised marriage, irrespective of amount or donor. Income from Other Sources The residual head of income under which taxable gifts and other receipts not falling under salary, house property, business or capital gains are charged to tax. Decriminalisation The removal of criminal liability for an act — here, consensual same-sex conduct — achieved in Navtej Singh Johar v Union of India, 2018. Legal Recognition The formal acknowledgment of a status (such as marriage) by law, carrying attached rights and benefits; distinct from mere social or personal acceptance. Statutory Interpretation The judicial process of determining the meaning of words used by the legislature in a statute, generally constrained by the text and legislative intent. Frequently Asked Questions FAQ Are gifts taxable in India under the Income-tax Act, 2025? Yes, in specified circumstances. Money, immovable property or specified movable property received without consideration, or for inadequate consideration, can be treated as income from other sources once statutory thresholds are crossed and no exemption applies. What is the ₹50,000 gift threshold? If the aggregate value of money received without consideration in a financial year exceeds ₹50,000, the entire aggregate amount becomes taxable — not merely the amount exceeding ₹50,000. Similar thresholds, with slightly different mechanics, apply to immovable property and specified movable property. Are gifts from relatives taxable? No. Gifts received from a person falling within the statutory definition of "relative" are generally fully exempt from tax, irrespective of the amount involved. Is a spouse treated as a relative? Yes. A spouse is expressly included within the statutory "relative" definition, so gifts between legally married spouses generally qualify for the relative exemption. Are wedding gifts taxable? Gifts received by an individual on the occasion of that individual's own legally recognised marriage are generally exempt, regardless of value or who the donor is. This is distinct from the relative exemption. Are gifts from friends taxable? Friends do not fall within the statutory "relative" definition. Monetary gifts from friends are taxable once the aggregate exceeds ₹50,000 in a year, unless another exemption, such as the marriage-occasion exemption, applies. Are gifts from a live-in partner taxable? A live-in partner who is not a legally recognised spouse does not fall within the statutory "relative" definition. Gifts above the threshold may therefore be taxable in the recipient's hands, subject to the specific facts and any other applicable exemption. Are same-sex partners treated as spouses under Indian tax law? Indian law does not currently recognise same-sex marriage. Because the relevant tax exemptions use the words "spouse" and "marriage", a same-sex partner may not automatically qualify for these specific exemptions. This remains an unresolved and actively debated area of law. What did Navtej Singh Johar v Union of India decide? In 2018, the Supreme Court decriminalised consensual same-sex conduct between adults by reading down Section 377 of the Indian Penal Code, grounding its reasoning in dignity, privacy and equality. It did not create marriage recognition. What did Supriyo v Union of India decide? In 2023, a five-judge Constitution Bench held that there is no unqualified fundamental right to marry enforceable in this manner, and declined to read same-sex marriage into the Special Marriage Act, leaving the question of legislative recognition to Parliament. Can a tax case change marriage law? A tax ruling, even if favourable to a taxpayer, would typically be confined to the specific fiscal provision in dispute. It would not, by itself, amount to legal recognition of same-sex marriage across all statutes; broader reform would most likely require legislative action or separate constitutional litigation. What records should be kept for large gifts? Keep bank transfer records, a gift deed where practical, evidence establishing the claimed relationship as a "relative", and, for marriage-occasion gifts, invitation cards, guest lists and photographs establishing the occasion and its legal character. Share This Key Takeaway A gift is taxed by law, not by love. Under the Income-tax Act, 2025, whether a gift is exempt depends on defined legal categories — "relative", "spouse", "marriage" — and Indian law does not yet recognise same-sex marriage, which is why the same act of giving can be tax-free for one couple and taxable for another. Copy Key Takeaway Conclusion "The real question is not whether love exists. The real question is whether the law recognises it. And until recognition catches up, even a gift can become a tax dispute." Follow Finedge by EduLaw for more legal-financial explainers Legal Anchors Sources / Legal Anchors Income-tax Act, 2025 — official text and commencement material, Income Tax Department, Government of India (in force from 1 April 2026, together with the Income-tax Rules, 2026). Income Tax Department guidance on deemed income including gifts — explaining the ₹50,000 threshold for money received without consideration, aggregation of monetary gifts, and taxation of the entire aggregate amount once the threshold is exceeded. Income Tax Department guidance on the meaning of "relative" for gift-exemption purposes, including the express inclusion of "spouse" within the definition, and the separate exemption for gifts received on the occasion of an individual's marriage. Navtej Singh Johar & Ors. v Union of India, Supreme Court of India, 2018 — decriminalising consensual same-sex conduct between adults by reading down Section 377 of the Indian Penal Code on grounds of dignity, privacy and equality. Supriyo @ Supriya Chakraborty & Anr. v Union of India, Supreme Court of India, 2023 — five-judge Constitution Bench declining to read same-sex marriage into the Special Marriage Act, 1954, and leaving legislative recognition of same-sex unions to Parliament. Disclaimer: This article is a general legal-educational explainer published by Finedge by EduLaw for citizen awareness and professional reference. It is not legal advice and should not be relied upon as a substitute for advice from a qualified professional on the specific facts of any case. Statutory provisions, thresholds and judicial positions referenced here are stated as understood and publicly available up to 07 July 2026 and may be amended, clarified or superseded by subsequent legislation, rules or judicial pronouncements. Readers dealing with an actual gift, tax, or recognition dispute should consult a qualified advocate or chartered accountant. Finedge by EduLaw — Legal & Financial Explainers for Citizens · © 2026 EduLaw. All rights reserved. (function(){ "use strict"; // Reading progress bar var bar = document.getElementById('progress-bar'); function updateProgress(){ var scrollTop = window.scrollY || document.documentElement.scrollTop; var docHeight = document.documentElement.scrollHeight - document.documentElement.clientHeight; var pct = docHeight > 0 ? (scrollTop / docHeight) * 100 : 0; if(bar){ bar.style.width = pct + '%'; } } window.addEventListener('scroll', updateProgress, {passive:true}); window.addEventListener('resize', updateProgress); updateProgress(); // Copy to share key takeaway var copyBtn = document.getElementById('copy-takeaway'); var feedback = document.getElementById('copy-feedback'); var takeawayText = document.getElementById('takeaway-text'); if(copyBtn){ copyBtn.addEventListener('click', function(){ var text = takeawayText ? takeawayText.textContent : ''; function showFeedback(msg){ if(feedback){ feedback.textContent = msg; setTimeout(function(){ feedback.textContent=''; }, 2500); } } if(navigator.clipboard && navigator.clipboard.writeText){ navigator.clipboard.writeText(text).then(function(){ showFeedback('Copied to clipboard!'); }).catch(function(){ fallbackCopy(text, showFeedback); }); } else { fallbackCopy(text, showFeedback); } }); } function fallbackCopy(text, cb){ try{ var ta = document.createElement('textarea'); ta.value = text; ta.style.position = 'fixed'; ta.style.left = '-9999px'; document.body.appendChild(ta); ta.focus(); ta.select(); document.execCommand('copy'); document.body.removeChild(ta); cb('Copied to clipboard!'); }catch(e){ cb('Could not copy automatically — please select and copy manually.'); } } // Close other open FAQ/example details when one opens (accordion behaviour), optional niceness var allFaq = document.querySelectorAll('details.faq'); allFaq.forEach(function(d){ d.addEventListener('toggle', function(){ if(d.open){ allFaq.forEach(function(other){ if(other !== d) other.open = false; }); } }); }); })();