It is recommended to add width, length, height attributes to product from admin panel.
To create a new attribute login to your website’s admin dashboard and navigate to the Stores>Attributes>Product section of Store
This will open the list of all attributes currently available on store. To create a new one click on the big orange Add New Attribute button.
Now you will be able to configure the attribute.
Attribute Code – The name of the attribute that will be used by the system
Scope – allows you to declare the attribute value saving scope like
Website - the value of this attribute for a product can be different in different Websites but have to stay the same between Store Views contained under the same Website.
Store View - the value of this attribute for a product can be different in all Websites and all Store Views
Website - the value of this attribute for a product can be different in different Websites but have to stay the same between Store Views contained under the same Website
Global - the value of this attribute for a product must be the same for all websites and stores
Unique Value – Set this to Yes, if you want the data saved in this attribute to be unique for each product. If you have different products made of the same material or having the same feature, leave this to No
Input Validation for Store Owner – If you want to validate the data before applying changes to the attribute, select Yes
Add to Column Options – To add this attribute to the list of column options please select Yes
Use in Filter Options – If you set this to Yes the attribute will be added to the list of filter options
From the menu on the left, click on the Storefront Properties tab to configure the frontend behavior of the attribute.
To save your new attribute click on the Save Attribute button on the top right corner of your screen. This will bring you back to the attributes list page on which you should see your new attribute.
For more refer to this short tutorial : https://www.fastcomet.com/tutorials/magento2/product-attributes