An electronic device comprising: a housing structure comprising a first housing and a second housing movably coupled to the first housing in a moving direction; a flexible display supported by the first housing and the second housing, wherein a size of a display area visible at a front surface of the housing structure is configured to change based on relative movement of the second housing with respect to the first housing; a detection sensor comprising a first electrode and a second electrode disposed side by side, and a dielectric disposed between the first electrode and the second electrode, and configured to detect a change in the size of the display area; and a processor, wherein the housing structure comprises an outlet, through which the flexible display is configured to be withdrawn from an internal space to the front surface of the housing structure or in which the flexible display is configured to be inserted from the front surface to the internal space, on the front surface of the housing structure, the detection sensor is disposed on a part of the housing structure adjacent to the outlet, such that the first electrode faces a surface of the flexible display passing through the outlet, and the detection sensor comprises a first portion having a length direction, and one or more second portions protruding from the first portion to another direction; wherein, based on changing the display area, the flexible display is configured to detect capacitance generated by the detection sensor through a region passing through the outlet, and the processor is configured to detect a change in the size of the display area through a region of the flexible display, in which the capacitance generated by the detection sensor is detected. a housing structure comprising a first housing and a second housing movably coupled to the first housing in a moving direction; a flexible display supported by the first housing and the second housing, wherein a size of a display area visible at a front surface of the housing structure is configured to change based on relative movement of the second housing with respect to the first housing; a detection sensor comprising a first electrode and a second electrode disposed side by side, and a dielectric disposed between the first electrode and the second electrode, and configured to detect a change in the size of the display area; and a processor, wherein the housing structure comprises an outlet, through which the flexible display is configured to be withdrawn from an internal space to the front surface of the housing structure or in which the flexible display is configured to be inserted from the front surface to the internal space, on the front surface of the housing structure, the detection sensor is disposed on a part of the housing structure adjacent to the outlet, such that the first electrode faces a surface of the flexible display passing through the outlet, and the detection sensor comprises a first portion having a length direction, and one or more second portions protruding from the first portion to another direction; wherein, based on changing the display area, the flexible display is configured to detect capacitance generated by the detection sensor through a region passing through the outlet, and the processor is configured to detect a change in the size of the display area through a region of the flexible display, in which the capacitance generated by the detection sensor is detected.