Color - Web APIs - MDN Web Docs

  • Skip to main content
  • Skip to search
Document: bgColor property

Deprecated: This feature is no longer recommended. Though some browsers might still support it, it may have already been removed from the relevant web standards, may be in the process of being dropped, or may only be kept for compatibility purposes. Avoid using it, and update existing code if possible; see the compatibility table at the bottom of this page to guide your decision. Be aware that this feature may cease to work at any time.

The deprecated bgColor property gets or sets the background color of the current document.

In this article

  • Value
  • Examples
  • Notes
  • Specifications
  • Browser compatibility

Value

A string representing the color as a word (e.g., "red") or hexadecimal value (e.g., "#ff0000").

When set to the null value, that null value is converted to the empty string (""), so document.bgColor = null is equivalent to document.bgColor = "".

Examples

jsdocument.bgColor = "darkblue";

Notes

The default value for this property in Firefox is white (#ffffff in hexadecimal).

document.bgColor is deprecated in the HTML specification. The recommended alternative is use of the CSS style background-color which can be accessed through the DOM with document.body.style.backgroundColor.

Specifications

Specification
HTML# dom-document-bgcolor

Browser compatibility

Help improve MDN

Was this page helpful to you? Yes No Learn how to contribute

This page was last modified on ⁨Jun 6, 2025⁩ by MDN contributors.

View this page on GitHub • Report a problem with this content Filter sidebar
  1. Document Object Model (DOM)
  2. Document
  3. Constructor
    1. Document()
  4. Instance properties
    1. activeElement
    2. activeViewTransition
    3. adoptedStyleSheets
    4. alinkColor Deprecated
    5. all Deprecated
    6. anchors Deprecated
    7. applets Deprecated
    8. bgColor Deprecated
    9. body
    10. characterSet
    11. childElementCount
    12. children
    13. compatMode
    14. contentType
    15. cookie
    16. currentScript
    17. defaultView
    18. designMode
    19. dir
    20. doctype
    21. documentElement
    22. documentURI
    23. domain Deprecated
    24. embeds
    25. featurePolicy Experimental
    26. fgColor Deprecated
    27. firstElementChild
    28. fonts
    29. forms
    30. fragmentDirective
    31. fullscreen Deprecated
    32. fullscreenElement
    33. fullscreenEnabled
    34. head
    35. hidden
    36. images
    37. implementation
    38. lastElementChild
    39. lastModified
    40. lastStyleSheetSet Non-standard Deprecated
    41. linkColor Deprecated
    42. links
    43. location
    44. pictureInPictureElement
    45. pictureInPictureEnabled
    46. plugins
    47. pointerLockElement
    48. preferredStyleSheetSet Non-standard Deprecated
    49. prerendering Experimental
    50. readyState
    51. referrer
    52. rootElement Deprecated
    53. scripts
    54. scrollingElement
    55. selectedStyleSheetSet Non-standard Deprecated
    56. styleSheets
    57. styleSheetSets Non-standard Deprecated
    58. timeline
    59. title
    60. URL
    61. visibilityState
    62. vlinkColor Deprecated
    63. xmlEncoding Deprecated
    64. xmlVersion Deprecated
  5. Static methods
    1. parseHTML() Experimental
    2. parseHTMLUnsafe()
  6. Instance methods
    1. adoptNode()
    2. append()
    3. ariaNotify() Experimental Non-standard
    4. browsingTopics() Non-standard Deprecated
    5. caretPositionFromPoint()
    6. caretRangeFromPoint() Non-standard
    7. clear() Deprecated
    8. close()
    9. createAttribute()
    10. createAttributeNS()
    11. createCDATASection()
    12. createComment()
    13. createDocumentFragment()
    14. createElement()
    15. createElementNS()
    16. createEvent() Deprecated
    17. createExpression()
    18. createNodeIterator()
    19. createNSResolver() Deprecated
    20. createProcessingInstruction()
    21. createRange()
    22. createTextNode()
    23. createTouch() Non-standard Deprecated
    24. createTouchList() Non-standard Deprecated
    25. createTreeWalker()
    26. elementFromPoint()
    27. elementsFromPoint()
    28. enableStyleSheetsForSet() Non-standard Deprecated
    29. evaluate()
    30. execCommand() Deprecated
    31. exitFullscreen()
    32. exitPictureInPicture()
    33. exitPointerLock()
    34. getAnimations()
    35. getElementById()
    36. getElementsByClassName()
    37. getElementsByName()
    38. getElementsByTagName()
    39. getElementsByTagNameNS()
    40. getSelection()
    41. hasFocus()
    42. hasPrivateToken() Experimental
    43. hasRedemptionRecord() Experimental
    44. hasStorageAccess()
    45. hasUnpartitionedCookieAccess()
    46. importNode()
    47. moveBefore()
    48. mozSetImageElement() Non-standard
    49. open()
    50. prepend()
    51. queryCommandEnabled() Non-standard Deprecated
    52. queryCommandState() Non-standard Deprecated
    53. queryCommandSupported() Non-standard Deprecated
    54. querySelector()
    55. querySelectorAll()
    56. releaseCapture() Non-standard
    57. replaceChildren()
    58. requestStorageAccess()
    59. requestStorageAccessFor() Experimental
    60. startViewTransition()
    61. write() Deprecated
    62. writeln() Deprecated
  7. Events
    1. afterscriptexecute Non-standard Deprecated
    2. beforescriptexecute Non-standard Deprecated
    3. DOMContentLoaded
    4. fullscreenchange
    5. fullscreenerror
    6. pointerlockchange
    7. pointerlockerror
    8. prerenderingchange Experimental
    9. readystatechange
    10. scroll
    11. scrollend
    12. scrollsnapchange Experimental
    13. scrollsnapchanging Experimental
    14. securitypolicyviolation
    15. selectionchange
    16. visibilitychange
  8. Inheritance
    1. Node
    2. EventTarget
  9. Related pages for DOM
    1. AbortController
    2. AbortSignal
    3. AbstractRange
    4. Attr
    5. CDATASection
    6. CharacterData
    7. Comment
    8. CustomEvent
    9. DOMError Deprecated
    10. DOMException
    11. DOMImplementation
    12. DOMParser
    13. DOMTokenList
    14. DocumentFragment
    15. DocumentType
    16. Element
    17. Event
    18. EventTarget
    19. HTMLCollection
    20. MutationObserver
    21. MutationRecord
    22. NamedNodeMap
    23. Node
    24. NodeIterator
    25. NodeList
    26. ProcessingInstruction
    27. QuotaExceededError Experimental
    28. Range
    29. ShadowRoot
    30. StaticRange
    31. Text
    32. TreeWalker
    33. XMLDocument
    34. XPathEvaluator
    35. XPathExpression
    36. XPathResult
    37. XSLTProcessor
  10. Guides
    1. Anatomy of the DOM
    2. Attribute reflection
    3. Selection and traversal on the DOM tree
    4. Building and updating the DOM tree
    5. Working with events

Từ khóa » Html De Bgcolor Nedir